• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

SOLVED Can I pass arguments to user events?

samspade

Member
You can't. Not really. If you know with certainty that the user event will go next, you could pass them to globals and use the globals in the event:

GML:
//some code
global.temp_1 = some_value;
global.temp_2 = random_num;
user_event(0);


//user event
if (global.temp_1) {
    another_value = global.temp_2;
}
But in 2.3 you can pass arguments to custom functions so while there are still a few times user events kind of work, I don't use them much anymore.
 

Yal

🐧 *penguin noises*
GMC Elder
User events has the advantage of not needing to exist for code calling them to compile, so if some code only needs to happen for some objects in a hierarchy, they're useful to cut down on boilerplate code.
 

Nidoking

Member
I still find them much simpler for the "function inheritance" style model because you can use event_inherited to call the parent event directly instead of having to worry about what name a function has at each level of the hierarchy or finding temporary names for functions or rewriting the functions at each level.
 
Top