Triggers - voxraygames/worldbuilding GitHub Wiki

Triggers are a generic system for causing changes to objects in the world.

An object can be a trigger source, a trigger destination, or both. A trigger source has a "tag", which is a string. When a player interacts with a trigger source, a message is broadcast with this tag to all trigger destinations. If the trigger destination has the same tag, it will perform some behavior.

For example, you can place a switch (a trigger source) in the world, and set its tag to "surprise". Then you can create a door (a trigger destination) and set its tag to "surprise" too. Finally, set the door's behavior to "rot+y_ccw". Now when the player interacts with the switch, the door will rotate counter-clockwise. If you add another door with the same tag "surprise", then both doors will rotate when the player flips the switch.

Currently the following behaviors are available:

  • Z-rotation behaviors

    • rot+x_ccw, rot+x_cw, rot-x_ccw, rot-x_cw, rot+y_ccw, rot+y_cw, rot-y_ccw, rot-y_cw
    • rot+x_push, rot+x_pull, rot-x_push, rot-x_pull, rot+y_push, rot+y_pull, rot-y_push, rot-y_pull

    description:

    • +x/-x/+y/-y: hinge point at default rotation
    • cw/ccw: clockwise/counter-clockwise
    • push/pull: away from player/toward player
  • Sliding behaviors

    • slide-x, slide-y, slide+x, slide+y

    description:

    • -x/-y/+x/+y: direction to slide
  • swap_model: swaps between two models, using the alternate_model field. Used for e.g. switches, lights, etc.

  • remove: Removes the object