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

Engine.THIS_REALM

The realm this script is executing in (Menu, Server or Client).

Engine.THIS_REALM: Engine.Realm

Functions

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: function): table)

Parameters

NameTypeDescription
callbackfun(sandbox: sandbox, require: function): tableThe 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

NameTypeDescription
eventTypestringThe event to listen for.
callbackfunctionThe callback to use.

Returns

NameTypeDescription
callbackfunctionThe callback that was registered.

Engine.removeEventListener

Removes an event listener.

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

Parameters

NameTypeDescription
eventTypestringThe event to remove the listener from.
callbackfunctionThe callback to remove.

Enums

Realm

The realms or environments in which scripts can execute.

Value
Menu
Server
Client

Events

"tick"

Fires every frame.

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

Parameters

NameTypeDescription
deltaTimenumberThe time in seconds since the last frame.