Log inGet started
Package

expressions.module

Newest version

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

README.md

expressions

The Expressions tab of the app menu: the expression menu the local player's avatar declares (the menu block of its avatar.json, see modules.avatarAnimator), drawn as rows a person works with a mouse, a finger, the keys or a pad. Each row sets one of the avatar's parameters through its AvatarAnimator:

  • a toggle reads On while its parameter holds its value, and a press sets the value or returns the parameter to its default;
  • a button holds its value for hold seconds, then returns the parameter to what it held before;
  • a submenu opens its items, with Back (and the menu's own back) leaving it;
  • a radial is a slider over one parameter from min to max, with − and + presses either side that step a tenth of the range;
  • an axis is two such sliders, one per parameter, each -1 to 1.

An avatar whose animator or menu reads the built-in Voice gets a microphone switch at the bottom of the top page. The tab shows while the avatar it drives declares a menu; its own words are the library catalog locales/<tag>/expressions.json, and an item's label is the avatar's, in the player's language when it is given per locale tag.

local expressions = require("@builtin::modules.api.engine.expressions")
appMenu.open("expressions")                      -- the tab in front of the person
expressions.setTarget(previewRoot.id)            -- drive an avatar stood in the editor
local tree = expressions.buildBody({ presentation = "desktop", width = 800, height = 600 })
expressions.onCallback("expressions:toggle:1")   -- press the first row, as a tap does
expressions.setTarget(nil)                       -- back to the local player's avatar

The rows are the elements expressions-<n> (the n-th item of the page shown, <a>.<b> inside a sub-menu, -less / -more on a puppet's presses, .a1 / .a2 for an axis puppet's two sliders), expressions-back and expressions-microphone; gui.clickElement presses them as a person does.