Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
LindaPeterson
Newbie


Joined: 13 Dec 2018
Posts: 1

PostPosted: 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?
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4692
Location: Pensacola, FL, USA

PostPosted: 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
Reply with quote
Leto
GURU


Joined: 27 Sep 2000
Posts: 90
Location: USA

PostPosted: 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
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net