Skip to content

Reference

This section is the detailed reference for ts2. For an introduction, start with Quick start.

The tags you write in markup.

  • Common props — the props every element accepts.
  • <layer> — a container, and the only element that may have children.
  • <rect> — a filled or outlined rectangle.
  • <text> — a text label.
  • <sprite> — an image or item icon.
  • <model> — a 3D model, item or NPC head.
  • <line> — a straight line.
  • <input> — an editable text field.
  • <ui> — the entry point the game opens.

Imported from 'ts2'. Called from a component.

  • useServerState — Reads a game variable or a skill, and makes the component follow it.
  • useSkill — Reads a skill’s current level, boosts included, and makes the component follow it.
  • useSkillBase — Reads a skill’s base level, ignoring boosts and drains, and makes the component follow it.
  • useInventory — Reads a container, and makes the component follow all of it.
  • predictServerState — Overwrites the client’s copy of a game variable, before the server confirms it.
  • useState — Reads a cell — private to this component, or a declaration shared across the interface — and returns its setter.
  • sessionState — Declares a cell shared between components, lasting until logout.
  • persistedState — Declares a cell saved on the player’s device.
  • useRef — Declares a handle to one component of this render, so a handler can change it, measure it, or bind to it.
  • createRef — Declares a ref at module scope — one name for one component in the project.
  • useInterval — Runs a body repeatedly, on a global clock, until it is stopped or cleared.
  • useDelay — Runs a body once, a set time after the component appears.
  • stopTimer — Takes the timer off a component — the one onTimer set, or a hook’s.
  • onMounted — Runs a body once, at the end of a component’s first render.
  • onUpdated — Runs a body at the end of every render of a component except its first.
  • useWatch — Runs a handler when a server value or a client occasion moves, without redrawing anything.
  • useRerenderOn — Redraws this component when the client announces an occasion.
  • useOnResize — Redraws this component when a resize of the game window changes a component’s size.
  • useUniverse — The box this component draws into, readable as it builds.
  • Engine — The ten occasions the client announces to an interface, for useWatch and useRerenderOn.
  • useDerived — Follows the result of a calculation over server state, rather than every value it reads.
  • useServerStateOnce — Reads a server value while the component builds, and follows nothing.
  • resumePauseButton — Answers a paused dialogue with which component was pressed.
  • param — Reads a parameter off an item, an NPC or an object by its reference — as a number, a string or a sprite.
  • defineEngineHooks — The project’s one declaration of what the client runs by name — world-map hooks and asset names.
  • intArray — A fixed-size array of whole numbers for one call of one function — and the read-only arrays a server call hands you.
  • Event — what a handler receives, and what is on it.
  • Types — the value types, the handle types and the geometry types.
  • Collections — lists, maps, records, containers, and the walks over them.
  • Globals — what is in scope without an import: positions, addresses, arithmetic, conversions.
  • Standard library — strings, arithmetic and the rest of what is in scope.
  • Supported syntax — which language constructs are available.