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

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  OnWorldSave()?
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

OnWorldSave()?

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


Posted by Candido   USA  (78 posts)  [Biography] bio
Date Sun 26 Jun 2011 10:29 AM (UTC)

Amended on Sun 26 Jun 2011 10:30 AM (UTC) by Candido

Message
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.
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #1 on Sun 26 Jun 2011 10:49 AM (UTC)

Amended on Sun 26 Jun 2011 10:50 AM (UTC) by Twisol

Message
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.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Candido   USA  (78 posts)  [Biography] bio
Date Reply #2 on Sun 26 Jun 2011 10:57 AM (UTC)
Message
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.
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] bio
Date Reply #3 on Sun 26 Jun 2011 08:15 PM (UTC)
Message
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.)
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #4 on Sun 26 Jun 2011 08:36 PM (UTC)
Message
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 :( )

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Sun 26 Jun 2011 09:56 PM (UTC)
Message
Candido said:

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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Candido   USA  (78 posts)  [Biography] bio
Date Reply #6 on Mon 27 Jun 2011 12:40 AM (UTC)
Message
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.
[Go to top] 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.


5,146 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] 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]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]