Legacy GM How are begin step / step / end step treated time wise?

Is there actually any definition of how long each stage of the step events take?

I assumed that each part of the step would be a third of the total step time, but using get_timer() in each event (in an otherwise empty object) showed that this is not the case. The vast majority of the time was in the end step.

Is that because in this example the lack of any code, other than the timer, meant it skipped quickly through begin / step, and end got everything of the step time that remained?

So begin step and step only last for as long as it takes to process all the functions inherent within them - such as alarms, input events, movement and collision. Then the end step is where all draw functions take place, and would effectively get the lions share if the previous two stages were relatively empty?
 

TsukaYuriko

☄️
Forum Staff
Moderator
They take as long as they need to finish executing all code in them across all instances of all objects.

Code execution does not wait for other events to complete as there is no need to do so and it would, in the worst case, negatively affect performance.

There are no "lion shares" as there inherently is no split allocation.


Also, the End Step event is certainly not "where all draw functions take place".
 
Also, the End Step event is certainly not "where all draw functions take place".
I appreciate the info regarding most of that. However, the quote there I may have worded wrongly (or have misunderstood) The draw events take place after the end step?
gms_event_order.png
I can never find in the manual where it lists how events play out, so this is from a Shaun Spalding video. I mistakenly thought the points in white were what happened in the orange steps. They are what happen in between / after those events?
 

samspade

Member
I appreciate the info regarding most of that. However, the quote there I may have worded wrongly (or have misunderstood) The draw events take place after the end step?
View attachment 24613
I can never find in the manual where it lists how events play out, so this is from a Shaun Spalding video. I mistakenly thought the points in white were what happened in the orange steps. They are what happen in between / after those events?
They order is the manual here: https://docs2.yoyogames.com/source/_build/2_interface/1_editors/events/index.html

Order is at the end. My understanding of how the manual words it is that all the other events probably have a given order as to where they occur but it might be changeable between platform or between builds (e.g. where alarms run for windows and macs could be different or they might be moved next year in an update). At least that is my interpretation (which could be wrong).
 
They order is the manual here: https://docs2.yoyogames.com/source/_build/2_interface/1_editors/events/index.html

Order is at the end. My understanding of how the manual words it is that all the other events probably have a given order as to where they occur but it might be changeable between platform or between builds (e.g. where alarms run for windows and macs could be different or they might be moved next year in an update). At least that is my interpretation (which could be wrong).
There is quite a lot of information missing there, when comparing what the manual tells you and to the image above (assuming it is correct) I'm using GMS 1.4, so maybe it had different information in the manual - but I could swear it had the same info as the picture above. I just don't know where to find it, since the obvious bit only tells you how step events are ordered and not anything else.

It's going to be tricky for me to figure out some things if other events aren't handled in a specific order anymore.
 

samspade

Member
There is quite a lot of information missing there, when comparing what the manual tells you and to the image above (assuming it is correct) I'm using GMS 1.4, so maybe it had different information in the manual - but I could swear it had the same info as the picture above. I just don't know where to find it, since the obvious bit only tells you how step events are ordered and not anything else.

It's going to be tricky for me to figure out some things if other events aren't handled in a specific order anymore.
GMS 1's Manual appears to be substantially similar: https://docs.yoyogames.com/source/dadiospice/000_using gamemaker/events/index.html.

From both manuals: "It should also be noted that the exact order that the events are going to occur in each step cannot be clearly stated, simply because it depends on the internal workings of GameMaker: Studio, which is subject to change as the software develops."

Again, I could be wrong, but I believe that is because the order of other events isn't supposed to be guaranteed. In other words, maybe alarms run before step events now, but YoYo wants the ability to make them run after step events later, so they are intentionally not saying where they run because they don't want us to rely on that order. Or maybe it is different by platform. Either way, the point is you shouldn't depend upon any order except the ones shown which are create, step, and draw. Everything else should be considered fluid for design purposes.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Again, I could be wrong, but I believe that is because the order of other events isn't supposed to be guaranteed. In other words, maybe alarms run before step events now, but YoYo wants the ability to make them run after step events later, so they are intentionally not saying where they run because they don't want us to rely on that order. Or maybe it is different by platform. Either way, the point is you shouldn't depend upon any order except the ones shown which are create, step, and draw. Everything else should be considered fluid for design purposes.
This is EXACTLY correct. The manual only states clearly those events that will always run in the same order regardless of platform or development status. All other events are subject to change and order should not be relied on for anything other than Create, Step and Draw. That said, you can find out for yourself when events are running simply by checking the "event_type" variable in every event...

Code:
show_debug_message("Current Event = " + string(event_type))
 
This is EXACTLY correct. The manual only states clearly those events that will always run in the same order regardless of platform or development status. All other events are subject to change and order should not be relied on for anything other than Create, Step and Draw. That said, you can find out for yourself when events are running simply by checking the "event_type" variable in every event...

Code:
show_debug_message("Current Event = " + string(event_type))
So there is know way to know when alarm events / collision checks are processed?
 
Either way, the point is you shouldn't depend upon any order except the ones shown which are create, step, and draw. Everything else should be considered fluid for design purposes.
Well, thanks for replying. It seems like I'll have to do a much more in-depth explanation of what I'm trying to do in another thread, as this hasn't cleared up the matter. Appreciate the response anyway :)
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
So there is know way to know when alarm events / collision checks are processed?
Yes. Use the code snippet I posted in the events and then call them and check the debug output. However, while the results may be valid for now or the platform you test, they may not be in the future or on another platform. That said WHY do you think you need to know this information? What are you wanting to do? In my experience, you shouldn't need to know this and if your game logic depends on when an event is fired then you're probably doing something wrong...
 
Yes. Use the code snippet I posted in the events and then call them and check the debug output. However, while the results may be valid for now or the platform you test, they may not be in the future or on another platform. That said WHY do you think you need to know this information? What are you wanting to do? In my experience, you shouldn't need to know this and if your game logic depends on when an event is fired then you're probably doing something wrong...
I have 37 instances in my current room as a stress test. They are looped through, going from highest bbox_bottom to lowest. The remaining 36 are then doing paths that may, or may not, end up going into an mp_grid (depending on where they are in relation to the object being checked)

The grid is 500 * 500 cells, that are a pixel in width / height, and needs recreating and refilling for each instance.

I don't know of any other way to do the AI that I require, so managing when it does certain stages of this "process" seems important. Currently I have 55 to 59 fps whereas previous efforts tanked it into the low 30s. That massive difference comes from noting how long things took, and then using the timer to see how much of a step had passed - if not enough time is left it holds off doing the next stage until a new step begins.

The tweaking that I have done is working. It takes no more than 2 to 3 seconds to go all through 37, and that's under stress test conditions without managing anything being done by the engine. I just want to find out what is causing the 4 or 5 fps frame drops, which means knowing where I don't have enough leg room. This means knowing what everything I'm not handling myself costs, and when it is happening.
 
If you are using GMS1 or GM8, you don't need to worry about event order changing across version, but there ARE differences across platforms. GMs2 is ever-changing, though.

GM will update xprevious and yprevious at the start (rendering them useless until you actually move).

Here's a thread that kinda went into things a tad:
https://forum.yoyogames.com/index.php?threads/events-priority.1995/#post-16470
Thanks for the reply. I probably should include in the description that its GMS 1 I'm using. Release platforms are windows pc, and possibly consoles. No mobile release. Given that GMS 1 is now discontinued with updates - the order of events described in that thread you linked to still holds true?

I'm not an expert by any means, and don't want to go into handling everything by myself just yet. So knowing what GMS is doing behind the scenes, when it's doing it, and how it works, is quite helpful. So, thanks again :)
 
Top