Skip to main content

Engine

API for engine-related functions.

Constants

Engine.WORLD_FORWARD_DIRECTION

The forward direction of the world.

Engine.WORLD_FORWARD_DIRECTION: vector

Engine.WORLD_UP_DIRECTION

The up direction of the world.

Engine.WORLD_UP_DIRECTION: vector

Engine.WORLD_RIGHT_DIRECTION

The right direction of the world.

Engine.WORLD_RIGHT_DIRECTION: vector

Functions

Engine.getWindowSize

Gets the size of the window.

Engine.getWindowSize(): number, number

Returns

NameTypeDescription
widthnumberThe width of the window.
heightnumberThe height of the window.

Engine.getCurrentTime

Gets the current time.

Engine.getCurrentTime(): number

Returns

NameTypeDescription
timenumberThe current time in seconds.

Engine.quit

Quits the game.

Engine.quit()

Engine.setAddonGlobals

Sets the global environment for addons.

Engine.setAddonGlobals(callback: fun(sandbox: sandbox, require: fun(path: string): any): table)

Parameters

NameTypeDefault ValueDescription
callbackfun(sandbox: sandbox, require: fun(path: string): any): tableRequiredThe callback which returns the global environment used for addons.

Engine.addEventListener

Adds an event listener. A list of events can be found here.

Engine.addEventListener(eventType: string, callback: function): function

Parameters

NameTypeDefault ValueDescription
eventTypestringRequiredThe event to listen for.
callbackfunctionRequiredThe callback to use.

Returns

NameTypeDescription
callbackfunctionThe callback that was registered.

Engine.removeEventListener

Removes an event listener.

Engine.removeEventListener(eventType: string, callback: function)

Parameters

NameTypeDefault ValueDescription
eventTypestringRequiredThe event to remove the listener from.
callbackfunctionRequiredThe callback to remove.

Events

"tick"

Fires every frame.

Engine.addEventListener("tick", function(deltaTime) end)

Parameters

NameTypeDescription
deltaTimenumberThe time in seconds since the last frame.