|
question about global var in plugin
|
Reply to this subject
Start a new subject
 
Refresh page
| Posted by |
Yeedoo
China (12 posts) bio
|
| Date |
Tue 13 Mar 2012 03:20 AM (UTC) [ quote
] |
| 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 (18,770 posts) bio
Forum Administrator |
| Date |
Reply #1 on Tue 13 Mar 2012 04:33 AM (UTC) [ quote
] |
| 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) [ quote
] 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.
821 views.
Reply to this subject
Start a new subject
 
Refresh page
top
Comments to:
Gammon Software support
Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )