Module game
Game related variables and functions.
level |
The current level the game is played on. |
playersCount |
The amount of players in the game. |
start |
The event handler for game start. |
tick |
The event handler for game tick. |
gameEvent |
The handler for gameEvents sent via player.postGameEvent. |
playerRemoved |
The event handler for player removing, whether by finishing or forfeiting the match. |
-
getPlayer (id)
-
Gets a player object by their index.
Remote player objects' variables are read-only. Exception is metadata, which can be both set and get.
Note: remote metadata is still local only.
Parameters:
- id
int
Index of the player.
Returns:
Returns the local/remote player object.
Usage:
game.getPlayer(1)
-
level
-
The current level the game is played on. Read-only.
-
playersCount
-
The amount of players in the game. Read-only.
-
start
-
The event handler for game start.
See also:
-
tick
-
The event handler for game tick.
See also:
-
gameEvent
-
The handler for gameEvents sent via player.postGameEvent.
Provides a gameEvent, from which you can get data and source (the player-sender).
tolua method must be used for every variable you get from the gameEvent.
Usage:
game.gameEvent.addListener(function(event) local data = tolua(event.data) local sender = tolua(event.source) end)
-
playerRemoved
-
The event handler for player removing, whether by finishing or forfeiting the match.
Provides the object of the removed player.
Usage:
game.playerRemoved.addListener(function(removedPlayer) end)