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
➜ MUSHclient
➜ Lua
➜ Sharing Lua data between plugins and global spaces
Sharing Lua data between plugins and global spaces
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Larkin
(278 posts) Bio
|
Date
| Wed 09 Mar 2005 06:51 PM (UTC) |
Message
| I'm trying to find a way (pretty much any way) to share data between plugins and/or the global space. I had thought that a sensible workaround might be to store things in MUSHclient variables and then get the data from there, but it doesn't seem to retrieve the variables correctly in my plugin.
I made an alias that calls some Lua code to process parameters and store the results in a MUSHclient variable. This alias is in the global space. Then, in my plugin I have a different alias that first checks the value of the MUSHclient variable before deciding whether or not to act. When I get the value in the plugin, however, it's always nil. Looking at the variables dialog shows that the variable exists and has the value "true" in it.
Any ideas? | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #1 on Wed 09 Mar 2005 07:00 PM (UTC) |
Message
| Are you using GetPluginVariable to get the Mushclient variable with the plugin? |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Larkin
(278 posts) Bio
|
Date
| Reply #2 on Wed 09 Mar 2005 07:32 PM (UTC) |
Message
| Nope. I'm actually using the Lua variables table script from Nick to access them. | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #3 on Wed 09 Mar 2005 07:49 PM (UTC) Amended on Wed 09 Mar 2005 07:55 PM (UTC) by Flannel
|
Message
| You'll either have to use GetPluginVariable directly (for that specific variable), or implement a second metatable (that uses [Get|Set]PluginVariable, since thats all the table script does, is save typing by linking get/setvariable to the tables metamethod) and obviously name it something other than var (global or whatnot) to access it. |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Larkin
(278 posts) Bio
|
Date
| Reply #4 on Wed 09 Mar 2005 08:02 PM (UTC) |
Message
| I did a sort of hack to workaround this, and I'm not sure if I should just go with this method or not. What I did was modify the the script from Nick to basically search a path for a specified variable name. It starts with the most often used plugin and then defaults to the world variable at the end.
Here's the modified indexer function:
-- called to access an entry
__index =
function (t, name)
local result
-- Check the tracking plugin first
result = GetPluginVariable ("7418e3f130e83fde1d68a401", name)
-- If the result is still nil, check the global space
if result == nil then
result = GetVariable(name)
end
return result
end;
| Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #5 on Wed 09 Mar 2005 08:45 PM (UTC) Amended on Wed 09 Mar 2005 08:48 PM (UTC) by Flannel
|
Message
| If youre getting a world variable from a plugin (which is what you said you were trying to do) you'll still need to use GetPluginVariable (with a null PID) since your GetVariable calls will find the (local) plugin variable, not the global one.
So if you'd like, you could use the PIDs and dynamically cycle through them (based on context) (including null for global where appropriate) and find the variable (and therefore you wouldn't need to store them intermediately in the world. Assuming you knew which plugin you wanted (for same variable names)). |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Larkin
(278 posts) Bio
|
Date
| Reply #6 on Thu 10 Mar 2005 01:36 PM (UTC) |
Message
| The reason I did the workaround and added the call to GetPluginVariable while keeping the GetVariable call is because the variables I had set in the plugin didn't go to the world and there was no way that I could see to make them go to the world, other than to have a global alias that set them there.
I designed the system to have a global alias to track afflictions or defenses and then the realm-specific tracking plugin would have certain override aliases for handling any special cases. If the plugin aliases try to set variables, they don't go in the same place, so I have to pass any values on to the global aliases.
I also didn't realize that I could use a nil plugin ID to get a world variable from anywhere. I think I may try that in this design to see how I like it. Thanks for the tip! | 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.
19,772 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top