GMS 2 Does Room End run before or after Clean Up?

Discussion in 'Programming' started by matharoo, Oct 11, 2019.

  1. matharoo

    matharoo Udemy Instructor

    Joined:
    Jul 9, 2016
    Posts:
    918
    Let's say I change the room using room_goto(). After that, in what order are the Room End and Clean Up events executed for every instance in the room?
     
  2. ParodyKnaveBob

    ParodyKnaveBob The Laughing Rogue

    Joined:
    Jun 23, 2016
    Posts:
    537
    Add a show_debug_message() or show_message() to each event and find out? $:^ } (Or, step through code? Either way, easy to test.)

    I hope this helps, $;^ J
     
    rIKmAN, IndianaBones and matharoo like this.
  3. nacho_chicken

    nacho_chicken Member

    Joined:
    Jun 21, 2016
    Posts:
    377
    According to the GMS2 documentation section on event order, Clean Up and Room End events aren't guaranteed to run either before or after the other. It would likely be best to change up your approach -- especially if you're doing some sort of tutorial or course -- so that you don't have to fix it in the future.
     
  4. matharoo

    matharoo Udemy Instructor

    Joined:
    Jul 9, 2016
    Posts:
    918
    Haha, right. Will do that.

    Well, it doesn't say anything about the order when it comes to those two events. It has to be one way or the other, right? That is why I asked.
     
  5. nacho_chicken

    nacho_chicken Member

    Joined:
    Jun 21, 2016
    Posts:
    377
    That part was talking about which events are 100% guaranteed, across all runtimes past and future of GMS2 to run in that order. Anything else has the possibility of changing at a moment's notice because you're relying on GM's internals not changing for your code to be stable. Like the section I linked says,
     
    matharoo likes this.
  6. matharoo

    matharoo Udemy Instructor

    Joined:
    Jul 9, 2016
    Posts:
    918
    Right. I was already trying to avoid depending on the order of those events, and now that it seems like there's no rigid order of their execution, I'll have to look for a different solution.
     
  7. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,896
    Clean up should be called after room end. The text for the clean up event pretty much says this:

    "This event will be called after any event that removes an instance of the object from the room. So, it will be triggered if the instance is destroyed, if the room ends, or if the game ends"

    PS: I'm with @ParodyKnaveBob in that you should test it and see! :p
     
  8. matharoo

    matharoo Udemy Instructor

    Joined:
    Jul 9, 2016
    Posts:
    918
    Thank you! And yes, I did test (after Bob suggested), and that's how it is. :) I should have tested instead of creating this thread haha, I have the dumb
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice