Skip to content

Scripting Guide

PegPeregoGaucho edited this page Aug 16, 2022 · 1 revision

XXL1 Scripting

Events

The developers used their own scripting system - "Events" - in order to connect all the interactive objects together in a level. Whenever a button is pressed, a pressure plate pushed down or a trigger entered by the player an event is executed. To inspect all the events in a level, open the Events window, which can be found under the "Scripting" section in form of a cogwheel.

Events contain a list of messages along with their target to change the behavior of different objects in the level, like opening a door or enabling a combat lock. In order for the event to be executed, its constraints on the bitmask must be satisfied. The bitmask consists of 8 bits (a byte) and has different behavior depending on the type of the event sequence:

An Or event sequence is executed whenever at least one of its bitmask bits is set.

An And event sequence is executed when all of its bitmask bits are set.

A Simultaneous event sequence is, like an And event sequence, executed when all of its bitmask bits are set, except that the set bits are cleared at the end of every frame.

Now, you may ask how exactly events are triggered. Objects contain event nodes which point to a specific event sequence and what bit of it to set. For example: when the hero hits a button, one of the event nodes of the button will be triggered. Example: EventNodeExample The shown button (CKHkActivator) contains exactly two event nodes:

the first event node points to the event sequence -1 and will set bit 0 (first bit). Of course -1 is not a valid sequence, so this means that no event sequence will be executed.

the second event node points to the event sequence 30 and will set bit 0 as well. By clicking the arrow [>] you can select the event sequence and inspect it in the Events window. As the constraints on the bitmask are satisfied by enabling the first bit, the event sequence will get triggered right away once the event node is executed.

Detectors

Detectors are shapes which will execute an event node whenever the hero or another object enters them. To view them in the editor, enable the "Detectors" checkbox in the main window at the bottom.

There are three different types of detectors: DetectorTypes

Rectangle detectors are triggered whenever an object passes through the side they are pointing to. The rectangle consists of a height, width and a direction.

Bounding box detectors are triggered whenever the object is inside the box. They are defined by two points: a high and low corner. An object is inside the box if its position is between the high and low corner.

Sphere detectors are triggered whenever the object is inside the radius of the sphere. Note that currently spheres are rendered as cubes.

Event sequences are attached to different detectors using the "Checklist". Each detector has one or more corresponding checklist entries that take care of executing the event sequence. A checklist entry consists of:

  • The scene node that can trigger it
  • Flags (on/off)
  • An event node which points to the event sequence which will be executed once the specified node enters the detector (see the above definition of an event node)

To edit the different detectors, open the Detectors window, which can be found under the "Scripting" category in form of a stickman going through a purple rectangle. A detector can be selected and its checklist entries inspected by clicking on the colored sphere in its center.

Clone this wiki locally