1. Hey! Guest! The 33rd GMC Jam will take place between May 23rd, 12:00 UTC (Friday noon) and May 27th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

Instance Order != Event Order?

Discussion in 'Programming' started by obscene, Mar 15, 2019.

  1. obscene

    obscene Member

    Joined:
    Jun 21, 2016
    Posts:
    2,354
    I've been experimenting with my in-game debugger trying to see if I can measure the impact of code in each Begin/Step/End/Alarms etc. Everything I know about GM says this is impossible to do accurately, but I just wanted to see where I could take it.

    Basically this is done by using get_timer() in each of these events in the debugger. Importantly, the debugger object is the first instance created in the game through creation code in the first room, though I've also tried placing them in the room and using the instance creation order in the room editor.

    I have no events in the Begin Step or End Step in any instance in the game (except the debugger itself), I'm only using Step or repeating Alarm[1] events.

    upload_2019-3-15_10-6-31.png

    A few issues I wanted some feedback on. First, the Begin Step time is calculated in Alarm[0].If I place any code in a repeating alarm[0] for any other instances in the game, the Begin Step graph jumps up So despite the fact my debugger is the first instance in-game, it's alarm[0] isn't running before the others. This is why I use alarm[1] for other instances. Apparently alarms execute in order.

    End Step is harder though. Like I said, I have nothing in the End Step and you can definitely see some action on the graph. I am generating waves of particles in the Step Event. At first I thought this must be GM internally calculating particle movements in the End Step? Not sure. However, another issue. I tried moving several instances into the End Step to see if the graph shifted from Step to End. It didn't. So again it looks like the debugger may not be executing its events first despite the fact it's the first instance.

    So.... fool's errand?
     
    Last edited: Mar 15, 2019
  2. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    3,969
    Anything that depends on instance ordering is a fool's errand in my book. You can't win when your design creates race conditions and makes the user experience depend on which horse wins. Beyond what's stated in the Manual's entry for Event Order, don't make any assumptions on what comes first.
     
  3. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,514
    Instance order has been somewhat Irrelevant for years now. I'm not even sure if it was even relevant in GM 8. Top priority is the event. GM will go through each event, then going through every object to see if that object has the corresponding event, then going through all of the instances of that object according to instance order to run that event. The draw event is the difference, where GM will compile a list based on the depth first, but even then I think it's still depth-object-instance. instance order was only ever really dominant in studio during the room generation event.

    And if you are using studio 2, well, don't rely on anything. LOL
     

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