Log inGet started
Package

Appearance.component

Newest version

This package holds more than this page lists. See all of its files in its world.

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