TriggerScript API Reference
    Preparing search index...

    TriggerScript reference

    TriggerScript is based loosely on JavaScript (specifically, a subset of ECMAScript 5 in Strict Mode). For basic information on statements, operators, expressions, conditionals, variables, and the like, consult basic JavaScript or ES5 tutorials or documentation.

    TriggerScript is still in development, many features are expected to change and be expanded upon. Do not be surprised if some scripts need re-writing as new features become available.

    Anatomy of a TriggerScript

    The body (the root scope) of a TriggerScript can contain only the following kinds of statements (besides comments):

    • Function declarations (helper functions to call in your handlers)
    • Calls to on* (e.g. onPressure or onInteract) APIs to register handlers

    Example:

    function helper(x) {
    return x + 1;
    }

    onInteract(function () {
    // Displays "3" when the player interacts with
    // the prop the script is attached to.
    say(helper(2));
    });

    Basic language features available

    The following are supported in TriggerScript and function approximately as they do in JavaScript:

    • variable declarations: var
    • conditionals: if
    • assignment operators: = += -= *= /= %= |= &= ^=
    • binary numeric/string operators: + - * / % & | ^ + - * / % | & ^ (note: the mathematical operators will always coerce to numbers if possible, and treat any truthy non-number as 1)
    • binary logic operators: == === != !== <= >= < > && ||
    • unary operators: ! - ~ typeof
    • // comments and /* comments */
    • global-scoped functions (cannot be declared within other functions)
    • Math object functions and properties

    Basic language features not yet implemented

    The following are not yet implemented in TriggerScript, but are planned:

    • loops: for while do
    • Object and Array data types

    Differences from JavaScript

    • Boolean values are represented as 0 and 1
    • undefined and null are represented as 0
    • functions can only be declared in the global scope (no functions within other functions)

    API Reference


    Type StoredValue

    StoredValue: string | number

    The types that can be stored in any persisted state or variable.


    Type EntityID

    A unique reference to an Entity.

    Entities are generally players or mobs, that can move independently in the world. Note that, depending on world settings, a single user may have more than one entity, and some users may not have an entity (e.g. if they are "Spectators").

    Players get new EntityIDs each time they join a world.

    Note: EntityIDs can be compared as strings and all EntityIDs will be strictly > "0" and < "Z", however a "lower" EntityID does not imply anything meaningful (only useful for sorting, checking uniqueness, etc).


    Function onAreaEntityCollide

    • Registers a function to be called when a player collides with another entity inside of an Area.

      Can only be called in the root scope. Only valid on Areas.

      Note: Due to online latency, this event is not symmetrical - on player A's client, they may collide with player B, but on player B's client, they may have already moved and never get a collision. Due to this, the important game logic should generally be done by whichever player is "chasing" the other, so that the act of catching someone feels good and responsive (for example, in a traditional game of tag, the one who is "it" is chasing, in a game of capture the flag, all of the ones without the flag are doing the chasing).

      Parameters

      Returns void

      onAreaEntityCollide(function (other_ent_id) {
      chatLocal('I touched ' + entityDisplayName(other_ent_id));
      });

    Function onAreaPlayerIn

    • Registers a function to be called when a player is inside of an Area.

      Can only be called in the root scope. Only valid on Areas.

      Parameters

      • f: () => void

      Returns void

      onAreaPlayerIn(function () {
      chatLocal('Hi!');
      });
    • Registers a function to be called repeatedly when a player is inside of an Area.

      Can only be called in the root scope. Only valid on Areas.

      Parameters

      • period: number
      • f: () => void

      Returns void

      onAreaPlayerIn(1000, function () {
      chatLocal('Hi!');
      });

    Function onInteract

    • Registers a function to be called when a player interacts with the prop.

      Can only be called in the root scope. Only valid on interactable props such as Trigger Buttons and Doors.

      Parameters

      • f: () => void

      Returns void

      onInteract(function () {
      chatLocal('Hi!');
      });

    Function onPressure

    • Registers a function to be called when a player stands on the prop.

      Can only be called in the root scope. Only valid on Trigger Pressure Plates, Trap Doors, and similar.

      Parameters

      • f: () => void

      Returns void

      onPressure(function () {
      chatLocal('Hi!');
      });
    • Registers a function to be called repeatedly when a player stands on the prop.

      Can only be called in the root scope. Only valid on Trigger Pressure Plates, Trap Doors, and similar.

      Parameters

      • period: number
      • f: () => void

      Returns void

      onPressure(1000, function () {
      chatLocal('Hi!');
      });

    Interface Math

    interface Math {
        E: number;
        LN10: number;
        LN2: number;
        LOG10E: number;
        LOG2E: number;
        PI: number;
        SQRT1_2: number;
        SQRT2: number;
        abs(x: number): number;
        acos(x: number): number;
        asin(x: number): number;
        atan(slope: number): number;
        atan2(y: number, x: number): number;
        ceil(x: number): number;
        cos(radians: number): number;
        exp(x: number): number;
        floor(x: number): number;
        log(x: number): number;
        max(a: number, b: number): number;
        min(a: number, b: number): number;
        pow(base: number, exponent: number): number;
        random(): number;
        round(x: number): number;
        sin(radians: number): number;
        sqrt(x: number): number;
        tan(radians: number): number;
    }
    Index

    Properties

    E: number

    The mathematical constant e. This is Euler's number, the base of natural logarithms.

    LN10: number

    The natural logarithm of 10.

    LN2: number

    The natural logarithm of 2.

    LOG10E: number

    The base-10 logarithm of e.

    LOG2E: number

    The base-2 logarithm of e.

    PI: number

    Pi. This is the ratio of the circumference of a circle to its diameter.

    SQRT1_2: number

    The square root of 0.5, or, equivalently, one divided by the square root of 2.

    SQRT2: number

    The square root of 2.

    Methods

    • Returns the absolute value of a number (the value without regard to whether it is positive or negative). For example, the absolute value of -5 is the same as the absolute value of 5.

      Parameters

      • x: number

      Returns number

    • Returns the arccosine (or inverse cosine) of a number.

      Parameters

      • x: number

      Returns number

    • Returns the arcsine of a number.

      Parameters

      • x: number

      Returns number

    • Returns the arctangent of a number.

      Parameters

      • slope: number

      Returns number

    • Returns the angle (in radians) between the X axis and the line going through both the origin and the given point.

      Parameters

      • y: number

        A number representing the Cartesian y-coordinate.

      • x: number

        A number representing the Cartesian x-coordinate.

      Returns number

    • Returns the smallest integer greater than or equal to its numeric argument.

      Parameters

      • x: number

      Returns number

    • Returns the cosine of a number.

      Parameters

      • radians: number

      Returns number

    • Returns e (the base of natural logarithms) raised to a power.

      Parameters

      • x: number

        A number representing the power of e.

      Returns number

    • Returns the greatest integer less than or equal to its numeric argument.

      Parameters

      • x: number

      Returns number

    • Returns the natural logarithm (base e) of a number.

      Parameters

      • x: number

      Returns number

    • Returns the larger of two numbers.

      Parameters

      • a: number
      • b: number

      Returns number

    • Returns the smaller of two numbers.

      Parameters

      • a: number
      • b: number

      Returns number

    • Returns the value of a base taken to a specified power.

      Parameters

      • base: number
      • exponent: number

      Returns number

    • Returns a supplied number rounded to the nearest integer.

      Parameters

      • x: number

      Returns number

    • Returns the sine of a number.

      Parameters

      • radians: number

      Returns number

    • Returns the square root of a number.

      Parameters

      • x: number

      Returns number

    • Returns the tangent of a number.

      Parameters

      • radians: number

      Returns number


    Function areaContainsEntity

    • Check if an entity exists nearby (within approximately /world_user_vis_dist) and is within the current or another Area.

      When using a tag to identify another Area, the maximum range (fully including the source and target) is 512 in each axis.

      An entity may not be nearby (and, therefore, no entity functions will work on them) in any of the following situations:

      • The target player has disconnected or otherwise no longer exists (e.g. trapped llamoo)
      • The player running the script is far away from the target

      If 0, or anything that is not an EntityID, is passed as ent_id, the result is always 0

      Parameters

      • tag: string | 0

        [String or 0] The optional tag identifying which Area to operate on

      • ent_id: 0 | EntityID

        [EntityID | 0] The Entity ID to query

      Returns 0 | 1

      onAreaEntityCollide(function (other_ent_id) {
      if (areaContainsEntity(other_ent_id)) {
      chatLocal('This is always true');
      }
      areaStateSet('last_collision', other_ent_id);
      });

      onAreaPlayerIn(1000, function () {
      if (areaContainsEntity(areaStateGet('last_collision'))) {
      chatLocal('This is only true if the entity is near us and within the Area');
      }
      });

    Function areaLocalGet

    • Get area-scoped local (not saved) state on the Area the script is on, or the prop is in, or another Area.

      Parameters

      • tag: string | 0

        [String or 0] The optional tag identifying which Area to operate on

      • field: string

        [String] The field name to get

      Returns StoredValue

      chatLocal('x = ' + areaLocalGet(0, 'x'));
      

    Function areaLocalSet

    • Set area-scoped local (not saved) state on the Area the script is on, or the prop is in, or another Area.

      Note: local state is not saved, not shared with other players, and will be reset upon a player leaving and returning to the world.

      Parameters

      • tag: string | 0

        [String or 0] The optional tag identifying which Area to operate on

      • field: string

        [String] The field name to set

      • value: StoredValue

        [String or Float or Integer] The value to set (0 clears)

      Returns void

      onAreaPlayerIn(1000, function() {
      areaLocalSet('time', areaLocalGet('time') + 1);
      if (areaLocalGet('time') > 10) {
      status('Time limit exceeded!');
      waygate('default');
      }
      });

    Function areaStateGet

    • Get area-scoped state from the Area the script is on, or the prop is in, or another Area.

      Note: Area state is shared between all players and all scripts within the Area.

      Parameters

      • tag: string | 0

        [String or 0] The optional tag identifying which Area to operate on

      • field: string

        [String] The field name to get

      Returns StoredValue

      chatLocal('x = ' + areaStateGet('x'));
      

    Function areaStateSet

    • Set area-scoped state on the Area the script is on, or the prop is in, or another Area.

      Note: Area state is shared between all players and all scripts within the Area.

      Parameters

      • tag: string | 0

        [String or 0] The optional tag identifying which Area to operate on

      • field: string

        [String] The field name to get

      • value: StoredValue

        [String or Float or Integer] The value to set (0 clears)

      Returns void

      areaStateSet('x', areaStateGet('x') + 1);
      

    Function bounce

    • Invert the player's vertical velocity, maintaining horizontal velocity, optionally adding velocity.

      Parameters

      • horiz_add: number

        [Float, 0..1] Additional horizontal velocity to apply (in the direction the prop is facing)

      • vert_add: number

        [Float, 0..1] Additional vertical velocity to apply

      Returns void

      bounce(0, 0);
      

    Function buffAdd

    • Add or remove time on a buff on the player.

      Parameters

      • buff_id: string

        [String] Buff ID to apply

      • delta_time: number

        [Integer, -7200..7200] Seconds to add or subtract

      Returns void

      buffAdd('sprint_m', 60);
      

    Function buffClear

    • Remove a specific or all buffs from the player.

      Parameters

      • buff_id: string

        [String] Buff ID to remove or "all"

      Returns void

      buffClear('sprint_m');
      

    Function buffSet

    • Set a buff on a player for a specific amount of time.

      Parameters

      • buff_id: string

        [String] Buff ID to apply

      • time: number

        [Integer, 0..7200] Seconds

      Returns void

      buffSet('sprint_m', 60);
      

    Function center

    • Center the player above the prop, instantly teleports them to the center of the Trigger, useful to chain before velSet().

      Returns void

      center();
      

    Function chance

    • Evaluates to 1 with the specified probability.

      Parameters

      • chance: number

        [Float, 0..1] The probability of returning 1

      Returns 0 | 1

      if (chance(0.1)) {
      chatLocal('You got lucky!');
      }

    Function chatBroadcast

    • Broadcast a chat message to ALL players in the world, and above the prop.

      Note: requires the script author to have /world_trigger_chat permissions.

      Parameters

      • message: string | number

        [Any] The message to display

      • ...extra: (string | number)[]

      Returns void

      chatBroadcast('Hi!');
      

    Function chatLocal

    • Display a message in local chat and above the prop to the player interacting with the Trigger.

      Parameters

      • message: string | number

        [Any] The message to display

      • ...extra: (string | number)[]

      Returns void

      chatLocal('Hi!');
      

    Function chatSay

    • Display a message above the prop to ALL players who are nearby.

      Only valid on Props.

      Parameters

      • message: string | number

        [Any] The message to display

      • ...extra: (string | number)[]

      Returns void

      chatSay('Hi!');
      

    Function damage

    • Apply a damage effect to the player.

      Parameters

      • horiz_vel: number

        [Float, 0..1] Horizontal velocity to assign to the player

      • vert_vel: number

        [Float, 0..1] Vertical velocity to assign to the player

      • stun_time: number

        [Float, 0..2] Seconds to stun the player

      • invuln_time: number

        [Float, 0..10] Seconds to make the player immune to other damage effects

      • energy_loss: number

        [Integer, 0..10000] Energy to remove from the player (if the current world has energy enabled)

      Returns void

      damage(0.35, 0.05, 0.35, 0, 500);
      

    Function energySet

    • Set the player's current Energy.

      Parameters

      • energy: number

        [Integer, 0...20000] Energy value

      Returns void

      energySet(10000);
      

    Function entityDisplayName

    • Get an entity's (Markdown-escaped) display name

      If the specified entity is not found, or ent_id is 0, returns "UNKNOWN"

      Note: If ent_id is "me", then this will return the current user's display name even if the active player does not have an entity (e.g. is a Spectator).

      Parameters

      • ent_id: 0 | EntityID | "me"

        [EntityID | 0 | "me"] The Entity ID to query or "me" for the active player

      Returns string

      onAreaEntityCollide(function (other_ent_id) {
      chatLocal('I, ' + entityDisplayName(0) + ', touched ' + entityDisplayName(other_ent_id));
      });

    Function entityExistsNearby

    • Check if an entity exists nearby (within approximately /world_user_vis_dist)

      An entity may not be nearby (and, therefore, no entity functions will work on them) in any of the following situations:

      • The target player has disconnected or otherwise no longer exists (e.g. trapped llamoo)
      • The player running the script is far away from the target

      If 0, or anything that is not an EntityID, is passed as ent_id, the result is always 0

      Parameters

      • ent_id: 0 | EntityID

        [EntityID | 0] The Entity ID to query

      Returns 0 | 1

      onAreaEntityCollide(function (other_ent_id) {
      if (entityExistsNearby(other_ent_id)) {
      chatLocal('This is always true');
      }
      areaStateSet('last_collision', other_ent_id);
      });

      onAreaPlayerIn(1000, function () {
      if (entityExistsNearby(areaStateGet('last_collision'))) {
      chatLocal('This is only true if the entity is near us');
      }
      });

    Function entityMyID

    • Get the active player's EntityID

      Note: This will return 0 if the active player does not have an entity (e.g. is a Spectator).

      Returns 0 | EntityID

      var my_id = entityMyID();
      if (my_id) {
      chatLocal('My name is ' + entityDisplayName(my_id));
      }

    Function entityStateGet

    • If the entity is a player, get user-scoped state from their "global" bag, otherwise get entity-scoped state.

      Parameters

      • ent_id: EntityID

        [EntityID] The Entity ID to query

      • field: string

        [String] The field name to get

      Returns StoredValue

      onAreaEntityCollide(function (other_ent_id) {
      chatLocal('Their title is ' + entityStateGet(other_ent_id, 'title'));
      });

    Function entityStateSet

    • If the entity is a player, set a user-scoped state in their "global" bag, otherwise set entity-scoped state.

      See userStateSet() for notes on special user state.

      Parameters

      • ent_id: EntityID

        [EntityID] The Entity ID to query

      • field: string

        [String] The field name to get

      • value: StoredValue

        [String or Float or Integer] The value to store (0 clears)

      Returns void

      onAreaEntityCollide(function (other_ent_id) {
      entityStateSet(other_ent_id, 'title', 'Tagged!');
      });

    Function entityType

    • Get an entity's type (e.g. "player" or "llamoo")

      If the specified entity is not found, or 0 is passed, returns "unknown"

      Parameters

      • ent_id: 0 | EntityID

        [EntityID | 0] The Entity ID to query

      Returns "player" | "llamoo" | "unknown"

      onAreaEntityCollide(function (other_ent_id) {
      chatLocal('I bumped into a ' + entityType(other_ent_id));
      });

    Function entityUserID

    • Get a player entity's User ID

      If the specified entity is not found, or 0 is passed, returns the empty string ('')

      Parameters

      • ent_id: 0 | EntityID

        [EntityID | 0] The Entity ID to query

      Returns string | 0

      onAreaEntityCollide(function (other_ent_id) {
      if (entityType(other_ent_id) === 'player') {
      chatLocal('I bumped into ' + entityUserID(other_ent_id));
      }
      });

    Function error

    • Display an error message and immediately stop script execution.

      Parameters

      • message: string

      Returns void

      error('Something went wrong');
      

    Function orient

    • Faces the player's camera in the direction of the Trigger.

      Returns void

      orient();
      

    Function propLocalGet

    • Get prop-scoped local (not saved) state from this or another nearby prop.

      Parameters

      • tag: string | 0

        [String or 0] The optional tag identifying which prop to operate on

      • field: string

        [String] The field name to get

      Returns StoredValue

      chatLocal('open = ' + propLocalGet(0, 'open'));
      

    Function propLocalSet

    • Set prop-scoped local (not saved) state on this or another nearby prop.

      Note: local state is not saved, not shared with other players, and will be reset upon a player leaving and returning to the world.

      Parameters

      • tag: string | 0

        [String or 0] The optional tag identifying which prop to operate on

      • field: string

        [String] The field name to set

      • value: StoredValue

        [String or Float or Integer] The value to set (0 clears)

      Returns void

      propLocalSet(0, 'open', propLocalGet(0, 'open') != 1);
      

    Function propLocalSetAll

    • Set prop-scoped local (not saved) state on all matching nearby props.

      Note: local state is not saved, not shared with other players, and will be reset upon a player leaving and returning to the world.

      Parameters

      • tag: string

        [String] The tag identifying which props to operate on

      • range: number

        [Integer, 1..32] The range in which to search for matching props

      • field: string

        [String] The field name to set

      • value: StoredValue

        [String or Float or Integer] The value to set (0 clears)

      Returns void

      propLocalSetAll('mydoor', 32, 'open', 1);
      

    Function propStateAdd

    • Add to a prop-scoped state on this or another nearby prop.

      Note: all players who interact with this Trigger share the same prop state.

      Note: if this script is on an Area, a tag is required and it will use the matching prop closest to the player and within the Area.

      Parameters

      • tag: string | 0

        [String or 0] The optional tag identifying which prop to operate on

      • field: string

        [String] The field name to set

      • addend: number

        [Float or Integer] The value to add

      Returns void

      propStateAdd(0, 'x', 1);
      

    Function propStateGet

    • Get prop-scoped state from this or another nearby prop.

      Note: if this script is on an Area, a tag is required and it will use the matching prop closest to the player and within the Area.

      Parameters

      • tag: string | 0

        [String or 0] The optional tag identifying which prop to operate on

      • field: string

        [String] The field name to get

      Returns StoredValue

      chatLocal('open = ' + propStateGet(0, 'open'));
      

    Function propStateSet

    • Set prop-scoped state on this or another nearby prop.

      Some props have states with special behaviors:

      • open on Doors opens the door
      • active on Indicators turns on the light or panel
      • title on any prop displays text floating above the prop

      Note: all players who interact with this Trigger share the same prop state.

      Note: if this script is on an Area, a tag is required and it will use the matching prop closest to the player and within the Area.

      Parameters

      • tag: string | 0

        [String or 0] The optional tag identifying which prop to operate on

      • field: string

        [String] The field name to set

      • value: StoredValue

        [String or Float or Integer] The value to set (0 clears)

      Returns void

      propStateSet(0, 'open', propStateGet(0, 'open') != 1);
      

    Function propStateSetAll

    • Set prop-scoped state on all matching nearby props.

      Note: all players who interact with this Trigger share the same prop state.

      Note: if this script is on an Area, a tag is required and it will use props found within a range around the player and within the Area.

      Parameters

      • tag: string

        [String] The tag identifying which props to operate on

      • range: number

        [Integer, 1..32] The range in which to search for matching props

      • field: string

        [String] The field name to set

      • value: StoredValue

        [String or Float or Integer] The value to set (0 clears)

      Returns void

      propStateSetAll('mydoor', 32, 'open', 1);
      

    Function randNum

    • Evaluates to a (floating point) number between 0 (inclusive) and max (exclusive).

      Parameters

      • max: number

        [Float] The (exclusive) maximum value to return

      Returns number

      velSet(0, 0.5 + randNum(0.5));
      

    Function randRange

    • Evaluates to an integer between 0 (inclusive) and max (exclusive).

      Parameters

      • max: number

        [Integer, 2..1e9] The (exclusive) maximum value to return

      Returns number

      chatLocal('Die rolled', randRange(6) + 1);
      

    Function soundPlay

    • Play a sound.

      Valid Sound IDs:

      • bounce
      • buff
      • damage
      • debuff
      • door_close
      • door_open
      • eat
      • indicator_off
      • indicator_on
      • pickup
      • velocity_set

      Parameters

      • sound_id: string

        [String] A valid Sound ID

      • volume: number

        [Float, 0..1] The volume at which to play the sound

      Returns void

      soundPlay('buff', 1);
      

    Function soundPlay3D

    • Play a sound coming from this or a tagged prop.

      See soundPlay() for list of Sound IDs

      Parameters

      • tag: string

        [String] The tag identifying which prop to teleport to

      • sound_id: string

        [String] A valid Sound ID

      • volume: number

        [Float, 0..1] The volume at which to play the sound

      Returns void

      soundPlay3D('mypanel', 'buff', 1);
      

    Function status

    • Display a message as a status message to the player interacting with the Trigger.

      Parameters

      • message: string | number

        [Any] The message to display

      • ...extra: (string | number)[]

      Returns void

      status('Hi!');
      

    Function stun

    • Disables player movement controls for a limited time, useful when combined velSet().

      Parameters

      • time: number

        [Float, 0..10] Seconds to stun the player

      Returns void

      stun(0.5);
      

    Function teleportRelative

    • Teleports the player a relative distance. For Triggers, this is relative to the direction the Trigger is facing (note that a Trigger is placed initially facing you). For Areas, this position is relative from the lowest coordinate (southwest bottom) corner of the Area.

      Note: maximum teleport distance is 32 voxels in Lost Frontier worlds, 1024 voxels otherwise. Use waygate() to teleport arbitrary distances in any world.

      Parameters

      • x: number

        [Float] distance right

      • y: number

        [Float] distance forward

      • z: number

        [Float] distance up

      Returns void

      teleportRelative(0, 2, 0);
      

    Function teleportToProp

    • Teleports the player to (on top of) a nearby prop by tag

      Note: prop most be within 32 voxels of the Trigger (or player, if this is called from an Area script). Use waygate() or teleportRelative() instead to teleport any distance.

      Parameters

      • tag: string

        [String] The tag identifying which prop to teleport to

      Returns void

      teleportToProp('mytarget');
      

    Function timeMs

    • Get the current time since the Unix epoch in milliseconds.

      Returns number

      var dt = timeMs() - propStateGet('last_time');
      chatLocal('Time since last visitor = ' + dt);
      propStateSet('last_time', timeMs());

    Function timeSeconds

    • Get the current time since the Unix epoch in seconds.

      Returns number

      var today = timeSeconds() / 60 / 60 / 24;
      

    Function userMyID

    • Get the active player's UserID

      Returns string

      chatLocal('I am ' + userMyID()));
      

    Function userStateAdd

    • Add to a user-scoped state on the current player.

      Parameters

      • field: string

        [String] The field name to get

      • addend: number

        [Float or Integer] The value to add

      Returns void

      userStateAdd('x', 1);
      

    Function userStateGet

    • Get user-scoped state from the current player.

      Parameters

      • field: string

        [String] The field name to get

      Returns StoredValue

      chatLocal('x = ' + userStateGet('x'));
      

    Function userStateSet

    • Set a user-scoped state on the current player.

      Some user states have special behaviors:

      • [global.]title displays under the player's name

      Note: User-scoped state is stored either in an "author" bag, accessible only by scripts on Triggers placed by the same author, or a "global" bag (the default), accessible by any Trigger (note that anyone with Area Builder access can effectively modify any state in the global bag, so generally the "author" bag is what you want for any gameplay state in an "Anyone Can Build" world).

      Note: User state in the "global" bag is also reflected as Entity state for any users with nearby entities.

      To put something in the author bag (e.g. to protect it), prefix a field with "author.", see /userstate for details.

      Parameters

      • field: string

        [String] The field name to get

      • value: StoredValue

        [String or Float or Integer] The value to store (0 clears)

      Returns void

      if (userStateGet('title')) {
      userStateSet('title', 0);
      } else {
      userStateSet('title', 'The King');
      }

    Function velSet

    • Set the player's velocity (jump).

      Parameters

      • horiz_vel: number

        [Float, 0..1] Horizontal velocity to assign to the player

      • vert_vel: number

        [Float, 0..1] Vertical velocity to assign to the player

      Returns void

      velSet(0, 0.18);
      

    Function waygate

    • Teleport the player to the specified waygate.

      Parameters

      • waygate_id: string

        [String] The Waygate ID to target

      Returns void

      waygate('default');