[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  question about global var in plugin
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: question about global var in plugin
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Posted by Yeedoo   China  (12 posts)  [Biography] bio
Date 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?
[Go to top] top

Posted by Nick Gammon   Australia  (19,348 posts)  [Biography] bio   Forum Administrator
Date 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
[Go to top] top

Posted by Yeedoo   China  (12 posts)  [Biography] 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!
[Go to top] 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.


1,297 views.

[New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]