|
LindaPeterson Newbie
Joined: 13 Dec 2018 Posts: 1
|
Posted: Thu Dec 13, 2018 1:51 pm
timing events |
I'm trying to figure out how long certain things in my mud take.
The way I'm thinking of doing it is by noting the start time and end in internal format, getting the difference, and displaying the difference in minutes and seconds.
It's common for programming languages to have a way of returning a date and a time in an internal format - a format that makes math on them much easier.
But I'm having trouble finding a function that will convert a time to an internal format.
Is there a function for that in zScript? |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Fri Dec 14, 2018 3:50 am |
The %time function should be what you are looking for.
#HELP %time gives more information.
You can pretty much specify whichever format you prefer. |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Leto GURU
Joined: 27 Sep 2000 Posts: 90 Location: USA
|
Posted: Mon Dec 17, 2018 9:25 pm |
%time isn't always very useful, especially when doing math on its results.
Here is what I would do.
Create a LUA function called 'now'.
Have this as its return statement.
Code: |
return (os.time(os.date("!*t"))) |
This returns the number of seconds from the Unix Epoch, which is defined as the 1st of January 1970. You can now use basic math to determine the time between events.
Trigger for Event A:
Code: |
#VAR timeA {@now()} |
Trigger for Event B:
Code: |
#VAR timeB {@now()} |
The time difference in seconds between the two events would be
Code: |
$time=@timeB-@timeA |
|
|
|
|
|
|