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

GML using alarms cuz code in create event don't run inmidietly.

Carloskhard

Member
So my problem is that a lot of code in the create event dont seem to activate inmidiatly.
For example:
I have an object that creates a ds_list.
Then another one that create an instance of that list in his "create event", however I got a problem saying the list was not found so I have to tell the object to wait one frame with an alarm and then create that instance calling the list and it works.
Even more.. if I call the variable from the draw event of the other bject it works..So i dont know where is the problem
So the problem is that I'm using a lot of alarms in objects because of this.How can I fix this?
 
Last edited:

samspade

Member
So my problem is that a lot of code in the create event dont seem to activate inmidiatly.
For example:
I have an object that creates a ds_list.
Then another one that create an instance of that list in his "create event", however I got a problem saying the list was not found so I have to tell the object to wait one frame with an alarm and then create that instance calling the list and it works.
Even more.. if I call the variable from the draw event of the other bject it works..So i dont know where is the problem
So the problem is that I'm using a lot of alarms in objects because of this.How can I fix this?
First, I assume you are making the ds_list global, as otherwise you couldn't access a ds_list created in one instance from another (without the instance id at least). Assuming you are though, likely the issue is that both create events are being run in the same step event and the checking instance is checking for it before the other instance is created (and therefore before the ds_list exists). An alarm of 1 step would solve this issue, but better would be to control the timing of creation.

The reason a draw event can reference it is create events run first. So by the time any instance's draw event runs, the ds_list will be created.
 

Carloskhard

Member
First, I assume you are making the ds_list global, as otherwise you couldn't access a ds_list created in one instance from another (without the instance id at least). Assuming you are though, likely the issue is that both create events are being run in the same step event and the checking instance is checking for it before the other instance is created (and therefore before the ds_list exists). An alarm of 1 step would solve this issue, but better would be to control the timing of creation.

The reason a draw event can reference it is create events run first. So by the time any instance's draw event runs, the ds_list will be created.
Thanks for the answer however I just found the solution (Yep,that was quick jaja) I leave the asnwer here for everyone:
In the room editor,there is a buttom called "instance order".You can go inside and decide the order in which the objects are called/created,so I just put the objects I wanted to execute first on top and problem solve!
 
Top