EventBlock class represents an event block in an event sheet. This is also used as the "current event" in the EventStack.
EventBlocks consist of conditions and actions and are either AND blocks (the default), running when all conditions are met, or OR blocks, running when any condition is met.
Construct tracks the "SOL modifiers" for each EventBlock. These are the ObjectClasses that the event may pick from, i.e. the SOLs that may be modified by running the event. This is an important consideration when working with events. Alterations to SOLs that are not in the SOL modifiers list are not permitted.
Retrigger() method is useful for implementing looping conditions. It should be used as such:
- Get the current event stack frame
- Push a new event stack frame
- In a loop:
- Push a copy of the SOL
- Retrigger the current event, passing both the old and new stack frames
- Pop the SOL
- Pop the event stack frame
- Return false from the condition method. (The event has already been executed the required number of times, and if it returns true, Construct will continue to run the event as normal, which is usually unnecessary.)
The following code example demonstrates the necessary calls.
// Get necessary references
const runtime = this._runtime;
const eventSheetManager = runtime.GetEventSheetManager();
const currentEvent = runtime.GetCurrentEvent();
const solModifiers = currentEvent.GetSolModifiers();
const eventStack = runtime.GetEventStack();
// Get current stack frame and push new one
const oldFrame = eventStack.GetCurrentStackFrame();
const newFrame = eventStack.Push(currentEvent);
for (const item of myArray)
// ... optionally update state here ...
// Push a copy of the current SOL
// Retrigger the current event, running a single loop iteration
// Pop the current SOL
// Pop the event stack frame
// Return false since event already executed