GML A function in event_inherited() to terminate the rest of children's code?

Dawn

Member
I want to add something like exit; in the parent's code so when the conditions are met children with event_inherited() won't run the rest of the code below it. Apparently exit; doesn't work as it only finishes what's inside the contents of event_inherited().

I could just add if statements for each child or just add everything in the parent's code but it feels like it's not the right way to do it. Is there any way to do this?
 

vdweller

Member
It's true, exit works only for the block of code you're currently in.

I guess a global variable flag or something similar will do the trick, have the parent set it to 1 and have the children exit upon checking if it's 1 or something.
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
The events are secretly scripts, so it makes sense that "exit" only terminates the executing one.

You could use a make a small wrapper like
Code:
/// event_inherited_ext()
globalvar __exit; __exit = false;
event_inherited();
return __exit;
Code:
/// exit_ext()
__exit = true;
return true;
and then
Code:
// parent event
if (dead) return exit_ext();
// ...
Code:
// child event
if (event_inherited_ext()) exit;
 
Top