In regards to the problem of returning from the middle of "repeatedly execute":
If there's multiple unrelated stuff updated there, like for example: update puzzle, update character position, update blinking lights on background, and so forth, then I do recommend moving unrelated parts of code into separate functions and call these functions from rep-exec. Then each part will be updated separately, not conflicting with each other.
For a dumb example:
Code: ags
If updating counters should be skipped awhole under some condition (like objects visible or not), then you may solve that by adding a early return like this:
Code: ags
PS. By the way, this "early return" code style is one that opposes the aforementioned Djikstra's proposal, apparently.
This pattern has its name in computer science, but I keep forgetting it.
If there's multiple unrelated stuff updated there, like for example: update puzzle, update character position, update blinking lights on background, and so forth, then I do recommend moving unrelated parts of code into separate functions and call these functions from rep-exec. Then each part will be updated separately, not conflicting with each other.
For a dumb example:
function UpdateTwoObjects()
{
// Idk if this code itself is correct, I'm just copy/pasting it for this example
if (object[1].Visible == true) { myCounter1 = 4; myCounter2 = 4; return; }
if (object[2].Visible == true) { myCounter3 = 4; myCounter4 = 4; return; }
}
function UpdateCounters()
{
// all the counter stuff
}
function room_RepExec()
{
UpdateTwoObjects();
UpdateCounters();
}
If updating counters should be skipped awhole under some condition (like objects visible or not), then you may solve that by adding a early return like this:
function UpdateCounters()
{
// don't update counters if something is off
if (some condition) { return; }
// all the counter stuff
}
PS. By the way, this "early return" code style is one that opposes the aforementioned Djikstra's proposal, apparently.
This pattern has its name in computer science, but I keep forgetting it.