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

Gammon Software Solutions forum

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

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  World Variables

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

World Variables

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Fadedparadox   USA  (91 posts)  [Biography] bio
Date Tue 19 May 2009 10:23 PM (UTC)  quote  ]
Message
I have my system in a plugin. I store all my lua variables in a MUSHclient variable. What I'm looking to do is then store that MUSHclient variable in the world, not the plugin. I know a number of ways around it, but all require something to be added to the world itself. Is there any way at all to do it from the plugin itself?

I've tried looking for a function such as SetPluginVariable or SetWorldVariable, but I can't find one. I've tried setting it on the world with setting x as the world and using x:SetVariable. Nothing seems to work.
[Go to top] top

Posted by Nick Gammon   Australia  (18,797 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Wed 20 May 2009 11:38 PM (UTC)  quote  ]
Message
This is by design. The whole idea of plugins is that they are supposed to be self-contained, and thus have their own:


  • Script space (including script language which can vary from plugin to plugin)
  • Script variables
  • MUSHclient variables (which are saved and restored if "save state" is specified)
  • Triggers
  • Aliases
  • Timers


If you were able to set a world variable (that is, in the "main world" variables space) then if different plugins chose to set the same variable name (eg. "counter" or "target") then they would interfere with each other, and also interfere with any main-world scripts or triggers/aliases etc.

The question is, why do you want to do this? There are work-arounds by making a plugin send to "execute" some text, which the main world can capture as an alias. Also, the main world can access a plugin's variables. So if you really need to talk to a plugin, the main world script can find out a plugin's variable, rather than the plugin setting the main world's variables.

- Nick Gammon

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

Posted by Fadedparadox   USA  (91 posts)  [Biography] bio
Date Reply #2 on Sat 23 May 2009 01:28 AM (UTC)  quote  ]
Message
I'm just looking for ways to simplify what's in my world file. I'm serializing all mushclient variables from the same scripts into a single variable, and reducing aliases to a single one and parsing them through lua instead.

Currently I use an alias to save plugin variables to the world, but this was something else I was hoping to remove the need for. Not possible then?
[Go to top] top

Posted by Nick Gammon   Australia  (18,797 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Sun 24 May 2009 04:58 AM (UTC)  quote  ]
Message
Isn't this making things more complicated than they need to be? Plugins already save their variables (if save_state = "y") so all you need to do is serialize script variables into MUSHclient variables in the OnPluginSaveState script callback, and then it all happens automatically. No need to push the variables into the main world and have it save them.

- Nick Gammon

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


2,096 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

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

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]