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
➜ question about global var in plugin
question about global var in plugin
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Yeedoo
China (12 posts) Bio
|
Date
| Tue 13 Mar 2012 03:20 AM (UTC) |
Message
| I defined a global var(a table) in my plugin script.
But every time i restart the world, The plugin keep those global var even i clear the 'save_state'.
I dont want the plug keep those global var.
My question is
1.how to make a clean plugin global namespace every time the plugin or the world restart.
2.Where are those plugin global var be stored?
Thank you! | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Tue 13 Mar 2012 04:33 AM (UTC) |
Message
| Some example code would help here.
Don't put variables into the plugin (in the <variable> part) because that will overwrite any variables saved in the state file.
If you have "save_state" set then each world/plugin combination saves its plugin variables into a file in the "state" subdirectory. The file name is a combination of the plugin ID and the world ID. eg.
a7046428ba477ebb729250df-d2fa45d390d935d947cdc169-state.xml
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Yeedoo
China (12 posts) Bio
|
Date
| Reply #2 on Tue 13 Mar 2012 07:29 AM (UTC) Amended on Tue 13 Mar 2012 07:30 AM (UTC) by Yeedoo
|
Message
|
Nick Gammon said:
Some example code would help here.
Don't put variables into the plugin (in the <variable> part) because that will overwrite any variables saved in the state file.
If you have "save_state" set then each world/plugin combination saves its plugin variables into a file in the "state" subdirectory. The file name is a combination of the plugin ID and the world ID. eg.
a7046428ba477ebb729250df-d2fa45d390d935d947cdc169-state.xml
Thank you very much Nick.
I check the code, found that it load a serialized table into a global var from the state file every time the plug installed.
I have always thinked that the var stored in _G namespace could also be stored when i leaved the world.
and now i see, Only the var saved in the state file could be kept, Is that right? | 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.
11,039 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top