Converting to/from lua and mushclient variables

Posted by Silencher on Mon 15 Jul 2013 10:21 PM — 4 posts, 18,592 views.

#0
It's mentioned in the wcript that you can load/save scripting variables ito mushclient variables at log in/log out. How is something like this done?

I was thinking about just aliasing 'quit' to do something like:

Quit

Setvariable (monsterskilled, monsterslain)
Where monsterslain is a script variable, but is that legal?

And visaversa:

Monsterslain = getvariable("monsterskilled") on login?
Australia Forum Administrator #1
Many plugins do that automatically. See:

http://www.gammon.com.au/forum/?id=4960
#2
Can you tell me which reply this is in?

As an aside, what does 'serialize' do?

It would be great if I could modify the plugin to load/save a table of variables I'd like to use.

Also: is there a way to check/compre current time to an old time, or current day/date with an old, variable saved date?

like oldDate would be 07/08/213

Trigger/timer/etc checks current date and compares to old date

If more than 1 week then
Statements
Else
Statements?
Australia Forum Administrator #3
You should really read the lot, but replies 6 and 7 summarize it.

Quote:

As an aside, what does 'serialize' do?


Turns the internal "binary" representation of numbers, strings, etc. into a printable string which can be saved in your state file. It also handles tables (including nested tables).

Quote:

Also: is there a way to check/compre current time to an old time, or current day/date with an old, variable saved date?


The function os.time() returns a number which is the number of seconds since January 1, 1970.

If you saved that in a variable, and then got the current time, and subtracted one from the other, you could work out how many seconds had elapsed.