Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit15ce14a4c1

README.md

Appearance

Carries how the person behind an avatar wears it, as one appearance document (modules.avatarAppearance), on the avatar root: the entity carrying Humanoid, which is player.avatar for a player. The document and a game's override rules are synced data of a few hundred bytes: every peer receives them and composes the same character on its own engine, so no mesh, bone or worn item is sent. Writing a new document recomposes only what differs from the one before.

local avatarAppearance = require("@builtin::modules.avatarAppearance")
local doc = avatarAppearance.new("@builtin::avatars.humanoid")
doc.body_shape = { height = 1.9 }
doc.colours = { body = "#3366cc" }
doc.worn = { { slot = "hat", item = "@builtin::meshes.cone", adjust = { y = 0.05, scale = 0.2 } } }

local body = layers.active.players.localPlayer.avatar  -- the avatar root (it carries Humanoid)
body.component.add("Appearance", {})
local look = body.component.get("Appearance")
look:wear(doc)                                         -- the person's document
look:override({ worn = { hat = "my_helmet" } })        -- the game's view of it
print(look:size(), look:address(), look:get().worn[1].item)
  • document (synced): the person's document as its canonical JSON. Emptied (:wear(nil)), the avatar returns to how it stood before the first document.
  • rules (synced): the game's override rules as JSON; the person's document stays as it is.
  • :wear(doc | nil), :get(), :effective(), :override(rules | nil), :address(), :size(), :emotes(), :composed().

Location: src/lua/lib/components/Appearance.component