Game module

The game module.

Usage

local Game = require('__stdlib__/stdlib/game')

Functions

get_player(mixed) Return a valid player object from event, index, string, or userdata
get_force(mixed) Return a valid force object from event, string, or userdata
print_all(msg[, condition]) Messages all players currently connected to the game.
get_or_set_data(sub_table[, index], key[, set][, value]) Gets or sets data in the global variable.

Functions

# get_player(mixed)

Return a valid player object from event, index, string, or userdata

Parameters: Returns:
# get_force(mixed)

Return a valid force object from event, string, or userdata

Parameters: Returns:
# print_all(msg[, condition])

Messages all players currently connected to the game.

Offline players are not counted as having received the message. If no players exist msg is stored in the global._print_queue table.

Parameters:
  • msg : (string) the message to send to players
  • condition : (nil or boolean) the condition to be true for a player to be messaged (optional)
Returns:
  • (uint) the number of players who received the message.
# get_or_set_data(sub_table[, index], key[, set][, value])

Gets or sets data in the global variable.

Parameters:
  • sub_table : (string) the name of the table to use to store data.
  • index : (mixed) an optional index to use for the sub_table (optional)
  • key : (mixed) the key to store the data in
  • set : (boolean) store the contents of value, when true return previously stored data (optional)
  • value : (mixed) when set is true set key to this value, if not set and key is empty store this (optional)
Returns:
  • (mixed) the chunk value stored at the key or the previous value