Time

From MiniScript Wiki
Revision as of 02:14, 13 May 2023 by JoeStrout (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

time returns the number of seconds since the script started running.

See also: wait, yield

Example

This example waits some random amount of time, then measures how long it takes you to react to a prompt by pressing a key. It does this by checking the value of time before (t0) and after (t1) the key.get call. Subtracting t0 from t1 gives the number of seconds between those times.

print "Get ready to press any key..."
wait 1 + 3*rnd
print "GO!"
t0 = time
key.get
t1 = time
print "That took you " + (t1 - t0) + " seconds.  Nice job!"