Does this still exist? I see a few mentions of it from several years ago, and then nothing. Couldn't find anything in release notes to indicate it was deprecated either. Needless to say I can't get it to work.
I have this in my script file.
function OnWorldSave()
Note("okay")
end
Tried save, save as, doing a SetChanged(true) and then saving. Nothing trips it.
There are no OnWorld* callbacks, per se. To set up an event callback from a non-plugin script file, you need to put the function's name into the appropriate field in the Scripting configuration page.
Alternatively you can use SetAlphaOption():
function OnWorldSave()
end
SetAlphaOption("on_world_save", "OnWorldSave")
For plugins, you can use the OnPluginWorldSave or OnPluginSaveState callbacks, depending on what you're trying to do.
Awesome, thanks. There doesn't happen to be a way to get stuff like PacketReceived or TelnetSubnegotation in the main world too, is there? I didn't see any alpha option for them. Always wondered what the design reason for limiting such powerful functions to plugins was.
Well, _technically_ you could change the question and ask why some people limit themselves to world files when you can have such beautiful plugins available to you. :)
The idea with plugins is that they are exchangeable, modular and all that stuff. The idea behind that again is, if I can venture a guess, that Nick wanted to make MUSHclient more accessible for new players; I know of plenty of people who are completely dependant on others for their scripting needs where it is all in a single script file. If the supplier changes something, it all gets wiped, and you are stuck without your changes once again.
Besides that, the world file takes special attention compared to plugins. Everything implemented for plugins needs to be implemented for the world file seperately, due to historical cruft piling up and rewriting the entire thing being simply too much work. Ideally, the world script space would be little more than a 'default' plugin, but at this time it is double work. (A similar comparison goes up for Lua vs other scripting languages.)
Worstje said: Ideally, the world script space would be little more than a 'default' plugin, but at this time it is double work.
Quite a bit more than double, unfortunately. It's been a qualm of mine for some time that the world script is treated differently from plugins, but you can usually work around it pretty well. (Unfortunately, there's no OnWorldBroadcast :( )
Awesome, thanks. There doesn't happen to be a way to get stuff like PacketReceived or TelnetSubnegotation in the main world too, is there? I didn't see any alpha option for them. Always wondered what the design reason for limiting such powerful functions to plugins was.
I honestly think you are better off making a plugin. The plugin wizard will do that for you in a few seconds, and then you can have the plugin open in a separate editor and tweak it, then just reload it to test.
Oh, I made my plugin for it long ago. I was just wondering about it because having it in the world would be easier/faster, and for something like, say, OnPluginLineReceived, it doesn't make much sense to me to have it only modular. Sure, if something changes in your ATCP subnegotiation, you'll be glad to just be able to switch out your plugin. However, if something changes in just straight up lines, you probably have bigger things to worry about.