[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, 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.
 Entire forum ➜ MUSHclient ➜ General ➜ Is there any event fired by script reloading?

Is there any event fired by script reloading?

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Hairui   China  (24 posts)  Bio
Date Tue 05 Jun 2007 04:25 AM (UTC)
Message

Many things can be done after the script reloaded, but how I can do things such as saving the data before the script to be reload?


Top

Posted by Shaun Biggs   USA  (644 posts)  Bio
Date Reply #1 on Tue 05 Jun 2007 05:19 AM (UTC)
Message
Do you mean like with SetVariable and GetVariable? You can use those to save data over sessions, and the plugins keep their own save states with their own variables.

It is much easier to fight for one's ideals than to live up to them.
Top

Posted by Nick Gammon   Australia  (23,046 posts)  Bio   Forum Administrator
Date Reply #2 on Tue 05 Jun 2007 06:23 AM (UTC)
Message
There is no specific event, for the main script, when the script is reloaded. It wouldn't be reliable anyway, because people usually reload because the script has crashed.

In a plugin, you can use OnPluginSaveState function to save things before the plugin saves its state (which it does when it is being reloaded), or OnPluginClose, which is called when the plugin is being closed.

I would tend to keep stuff in plugins, once debugged, because of the automatic saving.

If you don't want to do that, you could save periodically (say, every minute or five), so that if you have to reload, you haven't lost everything.

Another thing you could do is make your own alias for reloading the script file, which first calls a function (to save stuff), and then does:


world.DoCommand "ReloadScriptFile"



Then make an accelerator to overload Shift+Ctrl+R, so that if you use that to reload the script file, it still calls your alias.

http://www.gammon.com.au/scripts/doc.php?function=Accelerator


- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


13,504 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]