• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

Create_End event?



Would love to have a create_end event (like step_end) that runs after all the create events.
I've been faking it using an "initialized" flag, and checking for that on the first step, but it's a bit kludgy.

I seem to be running in to this a lot.
E.g. As part of the create event I have objects adding themselves to a list.
Then a 'master' object runs code against that list.
I have to have the master run it's init stuff during it's first step, as that's the only way to ensure all the other objects have had a chance to add themselves to the list.


If those objects are create before the master object they will be added to the list before the master object is created. So can you solve this by simply making sure the master object is create after all the other objects?


The create event doesn't really work like that. The create code will run when an instance is created. It wont wait for the next step or something before it will initialize. If you have an object that you need to do something after all the objects in a new room have been initilised, the room start event could be useful.

One aproach to having complete control over the order instances run their code is to have all code be called from one object using 'with' statements and scripts.

Eg you could have a step event like this in the master object:

with obj_player

with obj_enemy
By using this method you also aren't limited to begin step, step and end step. You can break each event up into as many bits as you need and reorder however you want


You can have an object create your other objects, and use code afterwards as the create_end event, remember that when you call instance_create(x,y,object) that it creates the object, runs it's creation code, and then AFTER that it continues with the rest of it's own code, sou you could have:

seperate create_end
instance_create(x,y,obj_first);//Creates an object
if obj_first.test_var1=10 room+=1;//This is the create_end event code, you can now allready read local variable(s) from object
instance_create(x,y,obj_second);//Creates another object
if obj_second.test_var1=10 room+=10;//This is the 2nd create_end event code, you can now read local variable(s) from object 2
and you'd end up in room 11.

OR you can have a single create_end event:
instance_create(x,y,obj_first);//Creates an object
instance_create(x,y,obj_second);//Creates another object
room= obj_first.var1 + obj_second.var1;//This is the create_end event code, you can now read local variable(s) from both objects
You'd end up in the room of both new object's local variables sum
Last edited by a moderator: