Players

This page documents the library responsible for most of player syncing, scripts/onlinePlay_player.lua, as well as scripts/battlePlayer.lua.

onlinePlayPlayers Functions

Function Returns Description
onlinePlayPlayers.ownsPlayer​(​player (Player)​) boolean Returns true if the player is the one being controlled, or false otherwise. Always returns true when not online.
onlinePlayPlayers.canMakeSound​(​player (Player)​) boolean Returns true if the player is on screen or is the player being followed by the camera. Always returns true when not online.

battlePlayer Functions

Function Returns Description
battlePlayer.getPlayerData​(​player (Player)​) table Returns the table used to store extra data about a player.
battlePlayer.getName​(​index (number)​) string Returns the player's username in online play. Offline, it returns either "P1" or "P2".
battlePlayer.getColor​(​index (number)​) Color Returns the color used to represent the player, such as with their outline.
battlePlayer.getPlayerHead​(​character (number)​) LuaImageResource Returns an image of the icon for the character's head, used in places such as the online chat. Considers the costume of the character, too.
battlePlayer.getPlayerIsActive​(​player (Player)​) boolean Returns false if the player has died and lost all of their lives or if they have disconnected from online play. Otherwise returns true.
battlePlayer.setPlayerIsActive​(​player (Player), active (boolean)​) nil Forces a player to be either active or inactive. Also calls battlePlayer.reset and sets forced state.
battlePlayer.getActivePlayers​(​player (Player)​) table Returns a list of the players considered to be "active".
battlePlayer.getActivePlayerCount​(​player (Player)​) number Returns the number of players considered to be "active".
battlePlayer.reset​(​player (Player)​) nil Resets most properties about the player, other than things such as character. Called when a player dies.
battlePlayer.getStartPoint​(​index (number)​) Vector2 Returns the start point of the player with that index.
battlePlayer.harmPlayer​(​player (Player), harmType (number)​) nil Harms the player with the given harm type. Harm type can be battlePlayer.HARM_TYPE.NORMAL, .SMALL_DAMAGE or .FREEZE. Note that, unlike harming the player normally, this has no sanity checks when online to cancel the harm if claiming the harm makes no sense (i.e., claiming damage for a player you have nothing to do with).