System¶
Reference¶
- system.getTime()¶
Returns the current player time in milliseconds
- system.getDeltaTime()¶
Returns the current player delta time between frames in milliseconds
- system.sleep(ms)¶
Waits for a given time in milliseconds
- system.markPromiseAsBlocking(promise)¶
A promise will be marked as blocking, meaning the execution of the current lifecycle function will not return unless this
Promise is fulfilled and the render pipeline will be blocked until then
- Parameters:¶
promise (
Promise
) – the promise to wait for
Examples¶
local System = require 'engine/system'
local Console = require 'engine/console'
local time = System.getTime()
Console.log(time)
local System = require 'engine/system'
local Console = require 'engine/console'
Console.log("Going to sleep for a second...")
System.sleep(1000):next(function()
Console.log("Hello again!")
end)
local System = require 'engine/system'
local Console = require 'engine/console'
function init()
Console.log("Going to sleep for a second...")
-- Mark this promise as blocking, so init() is not returned from unless this promise is also fulfilled.
-- This can be either done through System.markPromiseAsBlocking() or on the promise itself with :markAsBlocking()
System.sleep(1000):next(function()
Console.log("Hello again!")
end):markAsBlocking()
end
function render()
-- This will not execute until the sleep promise has fulfilled
end