PlayerComposition

Methods
9
Fields
2

Getting one

client:getLocalPlayer():getPlayerComposition()

Methods

MethodReturnsDescription
getEquipmentIds(){number}The equipment ids, one per KitType index: an item is ITEM_OFFSET + its id, a kit KIT_OFFSET + its id, 0 nothing. The player's own arr…
getEquipmentId(KitType)numberThe item worn in slot type, -1 for none (or a kit).
getKitId(KitType)numberThe kit in slot type, -1 for none (or an item).
getColors(){number}The five body colours; all 0 when the kit's colours could not be read.
getGender()number0 male, 1 female; 0 when the kit's gender could not be read.
isFemale()booleanWhether the gender is 1. getGender() is the value itself.
getTransformedNpcId()numberThe NPC the player renders as, -1 for none; -1 when the kit's NPC id could not be read.
setTransformedNpcId(number)()Render the player as NPC id (-1: as itself again), as the client's own model build reads its kit every frame; this composition's `getTran…
setHash()()Recompute the appearance hash from the player's kit (its equipment ids and colours) through the client's own hash, so the player's model fo…

Fields

FieldTypeDescription
KIT_OFFSETnumberWhat getEquipmentIds() adds to a kit id: 256.
ITEM_OFFSETnumberWhat getEquipmentIds() adds to an item id: 2048.

Returned by

MethodReturnsDescription
Player.getPlayerCompositionPlayerComposition?The player's appearance (worn equipment, colours, gender), as it is now; nil before one is decoded.

Method details

getEquipmentIds

getEquipmentIds: (PlayerComposition) -> {number}

The equipment ids, one per KitType index: an item is ITEM_OFFSET + its id, a kit KIT_OFFSET + its id, 0 nothing. The player's own array, as a 1-based view (like client:getIntStack()): ids[i] reads the player's kit now (the ids as read once the player has gone), #ids is 12, for i, id in ids walks it, and ids[i] = id writes the kit on the game thread, so setHash() then dresses the player (devtools' wear). The write raises on a client whose table has the kit writes off. This composition's getEquipmentId and getKitId keep the ids it was read with; after a new appearance a kept array reads the new ids. Copy it with a loop (ipairs and table.* take tables only).

setTransformedNpcId

setTransformedNpcId: (PlayerComposition, number) -> ()

Render the player as NPC id (-1: as itself again), as the client's own model build reads its kit every frame; this composition's getTransformedNpcId() keeps the value it was read with (ask getPlayerComposition() again). Game thread only; raises on a client whose table has the kit writes off.

setHash

setHash: (PlayerComposition) -> ()

Recompute the appearance hash from the player's kit (its equipment ids and colours) through the client's own hash, so the player's model follows a changed kit. Game thread only; raises on a client whose table has the kit writes off.