Time: Difference between revisions
Jump to navigation
Jump to search
imported>Dddaaannn (Note about t() alias for time().) |
imported>Felice Enellen (→Examples: syntax highlighting) |
||
| Line 10: | Line 10: | ||
== Examples == | == Examples == | ||
< | <syntaxhighlight lang="lua"> | ||
function _init() | function _init() | ||
last = time() | last = time() | ||
| Line 25: | Line 25: | ||
end | end | ||
end | end | ||
</ | </syntaxhighlight> | ||
== See also == | == See also == | ||
Revision as of 04:35, 13 February 2018
time( )
- Returns the amount of time since Pico-8 was last started, as a fractional number of seconds.
The time() function returns the fractional number of seconds since Pico-8 was started.
Note: This uses the built-in number type to represent the number of seconds, which has an upper limit of 32,767. (roughly 9h 6m)
t() is a short alias for time().
Examples
function _init()
last = time()
end
function _update()
-- (empty update to use game loop)
end
function _draw()
cls()
if (time() - last) > 10 then
print("time's up!", 44, 60, 7)
end
end