Register forum user name Search FAQ

Gammon Forum

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 ➜ Trigger to catch time trigger was fired

Trigger to catch time trigger was fired

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Silencher   (55 posts)  Bio
Date Fri 10 Apr 2015 12:31 PM (UTC)
Message
Can someone give me a sample trigger that, when fired, saves and stores the full date, time (hours/min/secs) it was fired to a variable? i'm not sure how to do this even after reading the Lua documentation
Top

Posted by Fiendish   USA  (2,536 posts)  Bio   Global Moderator
Date Reply #1 on Fri 10 Apr 2015 03:34 PM (UTC)

Amended on Fri 10 Apr 2015 03:41 PM (UTC) by Fiendish

Message
To get a table of the date and time ( http://lua-users.org/wiki/OsLibraryTutorial ):

os.date('*t')


To save that to an internal script variable, just assign it.

date_and_time = os.date('*t')


To save tables to a MUSHclient Variable though you have to serialize the table to a string and then later convert it back to a table from its serialized form.

So, per http://www.gammon.com.au/forum/?id=4960
To save it, you could do:

require "serialize"
date_and_time = os.date('*t')
SetVariable ("date_and_time", "date_and_time = " .. serialize.save_simple (date_and_time))


And then to load it later:

assert (loadstring (GetVariable ("date_and_time") or "")) ()


And then you'll again have a local script variable that contains a date/time table called date_and_time.

https://github.com/fiendish/aardwolfclientpackage
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.


10,721 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.