Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Plugins
➜ Plugin with saved states
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Simon
Sweden (39 posts) Bio
|
| Date
| Wed 06 Aug 2008 09:49 AM (UTC) |
| Message
| Hi,
I'm currently working on a bunch of stat-keeping plugins and I haven't really found anyway to keep plugin-data throughout sessions. The way it works with the normal world-file is that whenever you press ctrl-s it saves the states of all variables etc. This does not seem to be the case with plugins.
Is there anyway I can work around this?
Cheers
/Simon |
- "Where do you live, Simon?"
- "I live in the sick and wounded, doc."
Session 9 | | Top |
|
| Posted by
| Worstje
Netherlands (899 posts) Bio
|
| Date
| Reply #1 on Wed 06 Aug 2008 10:42 AM (UTC) |
| Message
| First of all, you should check if the plugins in question have the save_state flag set to yes. Maybe it's called slightly differently, but it is one of the options in the plugin wizard, so make a dummy plugin to check it (got no MUSHclient to check with atm.)
Second, you should make sure you are using MUSHclient variables, and not Lua variables (or whatever other language you may be using). Those aren't saved.
However, you can save those Lua variables from the OnPluginSaveState() callback by manually saving those values to a MUSHclient variable, and restoring them upon loading. Check the rest of the forums for examples - it's been done to death. :) | | Top |
|
| Posted by
| Simon
Sweden (39 posts) Bio
|
| Date
| Reply #2 on Wed 06 Aug 2008 11:27 AM (UTC) Amended on Wed 06 Aug 2008 11:42 AM (UTC) by Simon
|
| Message
| Hey!
And thanks for the help! I'm currently running my plugins with save_state="y". Maybe it's because I've been editing the plugin while having it running that the state hasn't been saved? I'm not sure. I'm not using script-variables, I'm using standard world (mush) variables for the information I want to save.
I guess that I don't have that problem then, although sometimes I have seen the error-message in mushclient that it couldn't save the state of the plugin. Does anyone know why that happens?
-- Edit
Now that I take a further look at it, that's exactly what the problem is. I have my plugins on an usb-memory, and it can't save the plugin-states to it. It says it can't create the file. Although I'm certain that the memory isn't full and that there is no write-protection there.
The problem was that the "state" folder wasn't created. Once I created that, the problem was solved.
Thanks for the help!
-- /Edit
Cheers,
Simp |
- "Where do you live, Simon?"
- "I live in the sick and wounded, doc."
Session 9 | | Top |
|
| Posted by
| Worstje
Netherlands (899 posts) Bio
|
| Date
| Reply #3 on Wed 06 Aug 2008 11:51 AM (UTC) |
| Message
| | I'm glad to hear your problem was solved. =) | | Top |
|
| Posted by
| Simon
Sweden (39 posts) Bio
|
| Date
| Reply #4 on Wed 06 Aug 2008 08:18 PM (UTC) |
| Message
| Hey again,
Now when I've had the time to look a bit more into the problem, there's another issue.
When I reload a plugin (which I do very often, since I work with them while using them), it overwrites the variables when I reload the plugin. Is there any way to set the variables to something in the script-file so they're not overwritten when reinstalling the plugin?
Best regards,
Simon |
- "Where do you live, Simon?"
- "I live in the sick and wounded, doc."
Session 9 | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #5 on Thu 07 Aug 2008 12:47 AM (UTC) |
| Message
| Check out this link near the bottom:
http://www.gammon.com.au/forum/?id=4960
Any variables you want to keep should be "serialized" as in the example, and loaded back in. That preserves them, even if you do a "reinstall plugin".
Don't use variables in the plugin file itself if you can help it. Because of the load order they will overwrite any changes you make by serializing them. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Simon
Sweden (39 posts) Bio
|
| Date
| Reply #6 on Thu 07 Aug 2008 11:12 AM (UTC) |
| Message
| I made something similiar to what you suggested nick, and it's working flawless! Awesome! Thanks for all the help!
Cheers,
Simp. |
- "Where do you live, Simon?"
- "I live in the sick and wounded, doc."
Session 9 | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
26,036 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top