Scripting

API reference

Script doors, levers, Areas, conversations and module events in Luau. Everything here is generated from the engine, so it matches the build it describes.

LuauProfile rpg.script/559 entries · generated from the engine

Runtime limits. One fresh heap per invocation; 20,000 dispatched steps, 16 charged native calls (2048 for light effects), 1 MiB live VM memory, 2 MiB cumulative growth and 4,096 allocation attempts. Native functions and userdata member/equality callbacks consume the call budget. Namespace/global resolution is bounded by this registry. No standard libraries or static-analysis guarantee; unknown globals/members fault with bounded hints. Declarations exported_properties/exported_functions retain their keys; light_effect selects the separate light profile.

Declarations

declaration.exported_properties

declaration
local exported_properties = {}

Declares the properties read by the engine. Keep this exact name when silencing lint.

BoundsLiteral top-level declaration; at most 16 properties.

declaration.exported_functions

declaration
local exported_functions = {}

Declares the dialogue entries read by the engine. Keep this exact name when silencing lint.

BoundsLiteral top-level declaration; bounded condition/effect entries.

declaration.light_effect

declaration
local light_effect = { tags = {"tag", "$property"}, self = true }

Selects the light-only OnUsed profile: 2048 charged callbacks, 256 distinct staged lights. Tier-1 uses and dialogue effects cannot coexist. Steps and VM allocation limits stay unchanged.

Bounds16 tags, 64 bytes each; exported string references resolved by cook; paged private Area index of 65536 objects and 262144 memberships (full count kept); 512 KiB copied input, 1026 objects and 4096 lights; 8192 cumulative bulk output items.

Events

OnUsed

event
(user: EventContext) -> ()

Defines the use handler. Light declarations select copied object/light access and light-only proposals; other handlers retain the uses transaction. Dialogue entries receive opaque EventContext.

BoundsTier-1 uses or declared light-effect transaction; fresh heap.

OnOpened

event
(user: EventContext) -> ()

Runs after a validated open commits. No return values; counter or light-only effects.

BoundsDoor shared edge or Container per-viewer subscription; Tier 1.

OnClosed

event
(user: EventContext) -> ()

Runs after a close commits, including Container access loss or departure.

BoundsDoor shared edge or Container per-viewer withdrawal; Tier 1.

OnEnter

event
(character: EventContext) -> ()

Runs on Area membership entry after Module join or old Area exit.

BoundsArea owner; Tier 1.

OnExit

event
(character: EventContext) -> ()

Runs on Area departure before destination entry or Module leave.

BoundsArea owner; Tier 1.

OnModuleStart

event
() -> ()

Runs after restore and recovery departures, before new joins.

BoundsModule owner; counter profile; Tier 1.

OnPlayerJoin

event
(character: EventContext) -> ()

Runs before the joining Character's Area entry.

BoundsModule owner; counter profile; Tier 1.

OnPlayerLeave

event
(character: EventContext) -> ()

Runs after the departing Character's Area exit.

BoundsModule owner; counter profile; Tier 1.

IsFirstStart

function
() -> boolean

Returns the captured first admitted start flag, saved atomically with the start event, including a faulting start.

BoundsOnly inside OnModuleStart.

OnMessage

event

Defining or accessing this name faults as reserved. Custom event handlers are deferred.

BoundsReserved; no promised signature.

Self

Self

type
declare extern type Self with

The Script host, with exported configuration and copied object members in the light profile.

BoundsInvocation lifetime; typed index; no persistent ID.

Self:GetProperty

function
(self: Self, name: string) -> boolean | number | string

Reads an exported property from the host's effective configuration. Unknown keys fault; metadata table edits cannot change the copied configuration.

BoundsExported key <=64 bytes; copied effective value.

self

property
Self

Identifies the Script host within this invocation. Equality is canonical; no persistent ID or World pointer is exposed.

BoundsOpaque invocation-local typed index; read-only.

Self:After

property

Defining or accessing this name faults as reserved. Timers are deferred.

BoundsReserved; no promised signature.

EventContext

EventContext

type
declare extern type EventContext with

The handler first argument; in light OnUsed it represents the using Character. It cannot read self configuration.

BoundsInvocation lifetime; typed index; copied object members in light profile.

EventContext.Name

property
string

The event's copied Character name remains available after disconnect or transfer.

BoundsRead-only captured Character name; at most 128 bytes.

Area

Area

property
Area

Queries copied objects in the event host Area, in instanced-placement order.

BoundsLight-effect profile; declared tags only.

Area.FindByTag

function
(tag: string) -> {Object}

Returns a dense array in placement order. More than 64 matches faults instead of truncating.

BoundsDeclared tag <=64 bytes; at most 64 results; bulk output charged.

Area.FindFirstByTag

function
(tag: string) -> Object?

Returns the first object in placement order or nil, even when more than 64 match.

BoundsDeclared tag <=64 bytes; bulk output charged.

Area.Send

property

Defining or accessing this name faults as reserved. Custom event delivery is deferred.

BoundsReserved; no promised signature.

Object

Object

type
declare extern type Object with

A copied object; equality is canonical. No persistent identity or live World access.

BoundsInvocation-local typed index.

Object.Name

property
string

The copied effective object name.

BoundsRead-only; <=128 bytes.

Object.Tags

property
{string}

Effective Blueprint and placement tags in sorted order. Editing the copy changes no object.

BoundsRead-only copied array; <=64 tags of <=64 bytes; bulk output charged.

Object.HasTag

function
(self: Object, tag: string) -> boolean

Tests copied effective tag membership.

BoundsTag <=64 bytes.

Object.GetLights

function
(self: Object) -> {Light}

Returns a dense array in ComponentId order. Self lights require the self capability.

BoundsAt most 8; bulk output charged.

Object.FindLight

function
(self: Object, name: string) -> Light?

Returns a named light or nil. Duplicate matching names fault.

BoundsName <=128 bytes; at most 8 inspected; bulk work charged.

Light

Light

type
declare extern type Light with

Reads copied baseline plus staged changes. Any fault discards every write. World validates the stamped proposal at commit.

BoundsInvocation-local typed index; 256 distinct staged writes.

Light.Enabled

property
boolean

Stages enabled state; subsequent reads see the write.

BoundsReadable and assignable; strict boolean.

Light.Intensity

property
number

Stages intensity; signed zero is canonicalized and subsequent reads see float32.

BoundsReadable and assignable; finite float32 0..100000.

Light.Color

property
{r: number, g: number, b: number}

Returns a copied color. Assign the complete r/g/b table to replace it; editing a returned table does not stage writes.

BoundsReadable and assignable; finite float32 channels 0..1; bulk output charged.

Light.Kind

property
string

The copied light kind.

BoundsRead-only; point or spot.

Light.Range

property
number

The copied light range.

BoundsRead-only; finite float32 .01..256.

Light.Shadows

property
boolean

Whether the authored light casts shadows.

BoundsRead-only.

Player

Player

property
Player

Reads copied player facts and stages the existing declared gold reward. It never accesses a live World object.

BoundsDialogue entries only.

Player.Level

function
() -> number?

Returns total level, or nil when the copied player has no build.

BoundsNo arguments.

Player.ClassLevel

function
(id: string) -> number?

Returns the copied class level, or nil without a build. An unknown rules key with a build faults.

BoundsRules key <=64 bytes.

Player.Alignment

function
() -> string?

Returns the copied alignment, or nil when unavailable.

BoundsNo arguments.

Player.SkillRanks

function
(id: string) -> number?

Returns copied skill ranks, or nil without a build. An unknown rules key with a build faults.

BoundsRules key <=64 bytes; half-rank precision.

Player.SkillUsable

function
(id: string) -> boolean?

Returns whether the copied build can use a skill, or nil without a build. Unknown rules keys fault when a build exists.

BoundsRules key <=64 bytes.

Player.Gold

function
() -> number

Returns copied gold including this entry's staged gold proposal.

BoundsNo arguments.

Player.ItemCount

function
(id: string) -> number

Returns the copied inventory count for a Blueprint, or zero when absent.

BoundsBlueprint UUID <=36 bytes; valid asset ID.

Player.ProposeGiveGold

function
(value: number) -> ()

Stages gold within the entry's literal give_gold envelope. Later Gold reads see it; faults discard all proposals.

BoundsInteger 0..1000000; declared give_gold envelope; once.

Quest

Quest

property
Quest

Reads the invocation's declared quest facts from copied context.

BoundsDialogue entries only.

Quest.Stage

function
(id: string) -> number

Returns the copied stage of a declared quest. Undeclared quests fault.

BoundsQuest UUID <=36 bytes; declared quest.

Quest.Done

function
(id: string) -> boolean

Returns whether a declared quest is complete. Undeclared quests fault.

BoundsQuest UUID <=36 bytes; declared quest.

Dialogue

Dialogue

property
Dialogue

Reads declared conversation facts and stages bounded variable proposals over copied input.

BoundsDialogue entries only.

Dialogue.Flag

function
(name: string) -> number

Returns a declared flag, defaulting to zero when unset. Undeclared names fault.

BoundsDeclared key <=64 bytes.

Dialogue.Variable

function
(name: string) -> number

Returns a declared variable, including this entry's proposals, or zero when unset. Undeclared names fault.

BoundsDeclared key <=64 bytes.

Dialogue.RewardClaimed

function
(name: string) -> boolean

Returns whether the declared reward was claimed. Undeclared names fault.

BoundsDeclared key <=64 bytes.

Dialogue.Check

function
(name: string) -> string?

Returns passed or failed for a resolved declared check, or nil when unresolved. Undeclared names fault.

BoundsDeclared key <=64 bytes.

Dialogue.Param

function
(name: string) -> any

Returns an entry parameter. Asset parameters are copied UUID strings; undeclared parameters fault. Tooling uses any because the type is supplied by the entry's literal parameter declaration.

BoundsDeclared key <=64 bytes; validated entry arguments.

Dialogue.ProposeSetVariable

function
(name: string, value: number) -> ()

Stages replacement of a declared variable for an effect entry. Later reads see the staged value; conditions cannot propose.

BoundsDeclared target <=64 bytes; integer -1000000000..1000000000; <=8 variable proposals.

Dialogue.ProposeAddVariable

function
(name: string, value: number) -> ()

Stages addition to a declared variable for an effect entry. The resulting value clamps to the variable bounds and later reads see it.

BoundsDeclared target <=64 bytes; integer -1000000000..1000000000; <=8 variable proposals.

Use counters

GetUses

function
() -> number

Reads the copied committed use count. Pending proposals do not change this value.

BoundsOnUsed; committed count, 0..1000000.

SetUses

function
(value: number) -> ()

Proposes the next durable use count. A successful OnUsed must publish the same count; any later fault discards the proposal.

BoundsOnUsed; integer 0..1000000; once per event.

PublishUses

function
(value: number) -> ()

Proposes the public use count. It must equal SetUses at successful completion of the transaction.

BoundsOnUsed; integer 0..1000000; once per event.