@usbx/state
Values shared between scripts
local state = require("@usbx/state")
Creates or gets the global State with the key. A key that exists with another default, scope or schema is an error.
state.create<T>(key: string, default: T?, schema:
Schema<T>) ->
State<T>
Use it forkeeping one value that every script shares for the whole game, like the round phase.
keyThe State key. Every script that creates it shares it.
defaultoptionalThe value before anything sets it.
schemaWhat values it accepts.
state.create_per_player
function#Creates or gets the per-player State with the key. options can show it as a Leaderstat.
Use it fortracking each player's own tokens or wins, which can also show on the leaderboard.
keyThe State key.
defaultoptionalEach player's value before anything sets it.
schemaWhat values it accepts.
optionsoptionalShows the value on the player list and the scoreboard.
Build a create_per_player callleaderboard
state.create_per_instance
function#Creates or gets the per-instance State with the key. A key that exists with another default, scope or schema is an error.
Use it forgiving every breakable crate or door its own health, all kept under one key.
keyThe State key.
defaultoptionalEach instance's value before anything sets it.
schemaWhat values it accepts.