Skip to content

Engine.player

Functions

Engine.player.getPlayer

local player = Engine.player.getPlayer(playerHandle)

Returns a Player, or nil when there is none. Called without an argument, returns the local player. A null handle raises an error.

Some useful fields and methods of Player:

Field Description
name() Name of the player.
unitHandle Handle of the unit the player controls. Null while dead.
teamIndex Team of the player.
deaths, betrays, suicides, teamKills Statistics of the match.
networkPlayerData Network information of the player.

See Player in the types for every field.

Engine.player.getLocalPlayerHandle

local handle = Engine.player.getLocalPlayerHandle(localPlayerIndex)

Returns the handle of a local player, or nil when there is none. localPlayerIndex defaults to 0, the only local player outside split screen.

Example

local player = Engine.player.getPlayer()
if player then
    Engine.terminal.print("You are {} and have {} deaths", player:name(), player.deaths)
end