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

Does create event take action instantly?

T

TypicalHog

Guest
Will new chunks that have been created run their create event code before being destroyed?

// Destroy all chunks
with (obj_chunk) {
instance_destroy();
}
// Create new chunks
with (obj_asteroid) {
scr_load_chunks(id);
}
// Destroy all chunks
with (obj_chunk) {
instance_destroy();
}
 
T

TypicalHog

Guest
only one way to find out
Actually I can't test that right now because I have changed so much stuff in my game, there are tons of bugs in the code/double code/renamed objects/broken code...
 
S

seanm

Guest
Just create a new project and test it in as simple a way as possible.
 

Weird Dragon

Wizard
GMC Elder
Will new chunks that have been created run their create event code before being destroyed?
...
Think logically about it: You can not destroy something before it has been created, that doesn't make any sense. So the create event has to have happened.

***

EDIT: Well an exception would be if you changed an instance into another instance without performing events with this function: instance_change(obj, perf); but then it is about changing an instance instead of creating an instance.
 
Last edited:
S

seanm

Guest
@Weird Dragon
The thing is that when you use
with instance_create

whatever you run in that code happens after the object has been created. Ie The objects create event will run, and then maybe the with instance_create code will run immediately after.

It might happen immediately after, or it might take a step for your new create event code to run
 

Weird Dragon

Wizard
GMC Elder
@Weird Dragon
The thing is that when you use
with instance_create

whatever you run in that code happens after the object has been created. Ie The objects create event will run, and then maybe the with instance_create code will run immediately after.

It might happen immediately after, or it might take a step for your new create event code to run
@seanm , it sounds rather confusing what you wrote. I am not sure what you mean.

The Create Event is performed when the instance is created.
 
Last edited:
S

seanm

Guest
What I was trying to say was.

if you run this code
Code:
with instance_create(x,y,object)
{
   x=60
}
The object will only be set to x=60 AFTER the objects create event.

But I am not sure how long it takes.
 

Weird Dragon

Wizard
GMC Elder
How is that relevant to this topic where the subject is whether the Create Event will be performed before the instance is destroyed?
 
S

seanm

Guest
Because he is running code through with instance_create, and not the create event.
 

TheouAegis

Member
The create event happens immediately. The instance_create() call itself includes the subroutine to perform the create event.

So...

Chunks will be destroyed
Chunks' variables will be inaccessible
New chunks will be created
New chunks variables will be accessible
New chunks will be destroyed
New chunks variables will be inaccessible
Code ends


So not sure what that code was intended to even do besides waste the CPU's time.
 

Weird Dragon

Wizard
GMC Elder
Because he is running code through with instance_create, and not the create event.
If the object has code in the Create Event then that code is performed when the instance is created and the instance is created when you execute the code instance_create(x,y,obj).
 
T

TypicalHog

Guest
The create event happens immediately. The instance_create() call itself includes the subroutine to perform the create event.

So...

Chunks will be destroyed
Chunks' variables will be inaccessible
New chunks will be created
New chunks variables will be accessible
New chunks will be destroyed
New chunks variables will be inaccessible
Code ends


So not sure what that code was intended to even do besides waste the CPU's time.
25 chunks are loaded around the spaceship and I load/unload them when necessary.
The code above runs at the end of the game, it unloads all chunks (and every chunk destroys objects that were inside it) but sometimes if you shoot asteroid hard enough it can go outside of the loaded chunks and will not be destroyed nor saved as it doesn't belong to any chunk anymore. Then I load chunks around such objects and destroy them (which makes them save the objects).
 
Top