Do any of the OnPlugin* functions get called when the world is first opened? I have some tables that I'm serializing on OnPluginSaveState(), so that they're saved when the world is closed, but I'm not sure where I should be unserializing them. Most of the examples I see use OnPluginInstall(), but that doesn't seem to run if I just close the world and open it back up. I _could_ use OnPluginConnect(), but it's not uncommon for a user to disconnect and connect without the plugin saving state, in which case the tables would get overwritten -- though I suppose I could serialize in OnPluginDisconnect()...
Anyways, if I want the plugin to serialize and unserialize its tables so that they're not lost when the world is closed, where should I do this?
My current code is as follows:
And it's not unserializing when I want it to (when I open the world after it's been closed).
And just to clarify: I actually _do_ need to serialize in order to save the tables when I close MUSHclient, yes?
Anyways, if I want the plugin to serialize and unserialize its tables so that they're not lost when the world is closed, where should I do this?
My current code is as follows:
function OnPluginSaveState()
Note("OnSaveState")
require "serialize"
SetVariable ("captures", "captures = " .. serialize.save_simple (captures))
SetVariable ("capturesecho", "capturesecho = " .. serialize.save_simple (capturesecho))
SetVariable ("capturesordernums", "capturesordernums = " .. serialize.save_simple (capturesordernums))
SetVariable ("capturesordernames", "capturesordernames = " .. serialize.save_simple (capturesordernames))
end
function OnPluginInstall()
Note("OnInstall")
assert (loadstring (GetVariable ("captures") or "")) ()
assert (loadstring (GetVariable ("capturesecho") or "")) ()
assert (loadstring (GetVariable ("capturesordernums") or "")) ()
assert (loadstring (GetVariable ("capturesordernames") or "")) ()
end
And it's not unserializing when I want it to (when I open the world after it's been closed).
And just to clarify: I actually _do_ need to serialize in order to save the tables when I close MUSHclient, yes?