onUpdate

This event gets triggered on every frame that the game runs, thus is framerate dependent. The callback function gets the deltaTime passed along with it, which measures the frametime in ms, useful for making e.g. timers.

In here you can put any code that you want to run every frame, although it is best practice to only run your code when needed, e.g. using Observers.

Use this event with caution, as it is triggered continuously once the game is launched.

Usage Example

init.lua
registerForEvent('onUpdate', function(deltaTime)

    print('It has been ' .. deltaTime .. ' ms since the last call')
    
end)

Last updated