• 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!

Help with priority creat event.

H

hiep

Guest
Hello !
I want to group some room to make them play the same music like (
if (global.music_group == "Normal") audio_play_sound(S_Love, 0, true);) I but it in my control object.

I change the global.music_group in the room creat but it happen after the my control object. Any solution for this ?

Thanks for advance !
 

TsukaYuriko

☄️
Forum Staff
Moderator
if (global.music_group == "Normal") audio_play_sound(S_Love, 0, true);)
8 out of 9 Tsukas (the ninth one is a squirrel) recommend properly formatting your code so it doesn't wink at your readers. It may make them feel uncomfortable, especially if the word "love" is mentioned in the same line. :p

By sheer chance, I just finished writing a post about the event order. Depending on it like your code currently does is not a good idea, though, as it can change at any point in time, as illustrated in that post. (For reference, the manual has a warning about this under the Event Order section.)

I suggest taking things into your own hands rather than leaving it up to the event order - handle whatever you need to handle at the exact moment you need it to be handled. That means either moving your music playing code to the room creation code or the music group assignment code to your controller object.

Personally, I'd leave it up to the controller (otherwise you'd have this code spread across multiple room creation codes) by using a switch statement that checks which room it's in in the Room Start event (by comparing the built-in variable room), then plays music accordingly.
 
Top