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, confirm your email, resolve issues, 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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUDs ➜ MUD Design Concepts ➜ Use of SetVariable from within a plugin

Use of SetVariable from within a plugin

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


Posted by Seriley   (42 posts)  Bio
Date Tue 08 Jun 2010 11:16 PM (UTC)
Message
When I use SetVariable (stuff) in an OnWorldSave event, I expected the variable to be added to my world variable list because I thought that was where the variable was stored with this function.

I'm using simple serialization so I have a loadstring counterpart.

What I'm finding is the variables are being stored in the Plugin's list of variables, not the world's list as I had expected. I can see them there when I do:

/for k,v in pairs(GetPluginVariableList (GetPluginList ()[2])) do print(k) end

from the command line.

Am I doing something wrong?
Top

Posted by Seriley   (42 posts)  Bio
Date Reply #1 on Tue 08 Jun 2010 11:34 PM (UTC)
Message
I should mention that I require "var" in this plugin
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #2 on Wed 09 Jun 2010 12:25 AM (UTC)

Amended on Wed 09 Jun 2010 12:26 AM (UTC) by Twisol

Message
When you SetVariable() in a plugin, the variable is associated with the specific script space you called it from. Every plugin gets its own space, and the world has its own as well. You can't modify variables in other script spaces (i.e. the world or other plugins), but you can access them with GetPluginVariable() (using "" for the ID to get the world's variables).

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Seriley   (42 posts)  Bio
Date Reply #3 on Wed 09 Jun 2010 03:08 AM (UTC)
Message
I understand now. Thank you, Twisol, for your explanation
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,293 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

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