Use of SetVariable from within a plugin

Posted by Seriley on Tue 08 Jun 2010 11:16 PM — 4 posts, 17,361 views.

#0
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?
#1
I should mention that I require "var" in this plugin
USA #2
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).
Amended on Wed 09 Jun 2010 12:26 AM by Twisol
#3
I understand now. Thank you, Twisol, for your explanation