Player global creation.
This module adds player helper functions, it does not automatically register events unless Player.register_events() is called
local Player = require('__stdlib__/stdlib/event/player').register_events()
-- The fist time this is required it will register player creation events
get(player) | Get game.players[index] & global.players[index] , or create global.players[index] if it doesn’t exist. |
pdata(index) | Get the players saved data table. |
add_data_all(data) | Merge a copy of the passed data to all players in global.players . |
remove(event) | Remove data for a player when they are deleted. |
init([event][, overwrite=false]) | Init or re-init a player or players. |
Get game.players[index]
& global.players[index]
, or create global.players[index]
if it doesn’t exist.
Parameters: Returns: Usage:
local Player = require('__stdlib__/stdlib/event/player')
local player, player_data = Player.get(event.player_index)
Get the players saved data table.
Creates it if it doesn’t exsist.
Parameters:Merge a copy of the passed data to all players in global.players
.
Parameters:
local data = {a = 'abc', b = 'def'}
Player.add_data_all(data)