Is it possible to create loops in my Plugin SDK 2? In the old SDK 1, loops work as expected and perform their function successfully. However, in SDK 2, I can't seem to create loops that execute for each element or a specific number of times. Below is an example script I made in `conditions.js` (I created this script after extensively searching through the Construct 3 documentation, and this script only progressed to `GetSolModificators()`, but with an error due to `GetCurrentEvent()` returning null, even though I followed the documentation):
TestLoop(Count) {
const runtime = this.runtime;
const eventSheetManager = new C3.EventSheetManager(runtime);
const eventStack = eventSheetManager.GetEventStack();
const oldFrame = eventStack.GetCurrentStackFrame();
const currentEvent = oldFrame.GetCurrentEvent();
const solModifiers = currentEvent.GetSolModifiers();
const newFrame = eventStack.Push(currentEvent);
for (let i = 0; i < Count; i++) {
// ... optionally update state here ...
// Push a copy of the current SOL
eventSheetManager.PushCopySol(solModifiers);
// Retrigger the current event, running a single loop iteration
eventSheet.Retrigger(oldFrame, newFrame);
// Pop the current SOL
eventSheetManager.PopSol(solModifiers);
}
// Pop the event stack frame
eventStack.Pop();
// Return false since event already executed
return false;
}
The `aces.json` is as follows:
{
"highlight": false,
"id": "TestLoop",
"isLooping": true,
"isAsync": false,
"isInvertible": false,
"params": [
{
"id": "Count",
"type": "number"
}
],
"scriptName": "TestLoop"
}
After creating a new project, adding this loop and actions to it on layout start or button press, an error appears in the console:
If anyone can help me fix the error so I can finally create loops in Plugin SDK 2, I would be very grateful!