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

Why isn't it working?

S

seojaeoh

Guest
Create blackbox, yellowbox, and greenbox in the object compartment, and greenbox creates blackbox in its place with Instance2 when the space key is pressed, blackbox disappears when it is created, and yellowbox is created 4 seconds later.

object 0 =>blackbox object 1 =>yellowbox

greenbox
1.keydown
instance_create_layer(x+0, y+0, "Instances2", object0);

blackbox
1.create:
var a;
a = 1;
instance_destroy();
if(a == 1)
{
alarm[0] = room_speed * 4 ;
}
2.alarm0:
instance_create_layer(x+0, y+0, "Instances2", object1);

yellowbox
nothing

(greenbox=>create black box =>black box destroy and create yellow box)

I'd appreciate it if you could let me know.
 

samspade

Member
Create blackbox, yellowbox, and greenbox in the object compartment, and greenbox creates blackbox in its place with Instance2 when the space key is pressed, blackbox disappears when it is created, and yellowbox is created 4 seconds later.

object 0 =>blackbox object 1 =>yellowbox

greenbox
1.keydown
instance_create_layer(x+0, y+0, "Instances2", object0);

blackbox
1.create:
var a;
a = 1;
instance_destroy();
if(a == 1)
{
alarm[0] = room_speed * 4 ;
}
2.alarm0:
instance_create_layer(x+0, y+0, "Instances2", object1);

yellowbox
nothing

(greenbox=>create black box =>black box destroy and create yellow box)

I'd appreciate it if you could let me know.
If you destroy an instance, its alarm can't keep counting down. So you create and destroy the black box before it can do anything.
 
What is going on in that code? I honestly don't understand it.

In black box, put this:
Create
Code:
alarm[0] = room_speed*4;
Alarm[0] Event
Code:
instance_create_layer(x,y,"Instances2",object1);
instance_destroy();
Also, why are you creating things at x+0,y+0? It's not going to break anything, but why put +0 when it literally does nothing? And why initialise a = 1, and then simply have if (a == 1) immediately after it? Again, there's -no- reason for that whatsoever, just have the alarm be set on it's own...
 
S

seojaeoh

Guest
The destroy function destroys the next function as soon as it works. Thank you. But I heard that game maker is providing C language. I wonder if game maker has all C language functions or other forms.

I remember that the destroy function is the only function that destroys it. Is there a wait function instead of an alarm function? I heard it disappeared from game maker 2.

Thank you for being kind to people you don't know. everyone. :)
 
Last edited by a moderator:

samspade

Member
I remember that the destroy function is the only function that destroys it. Is there a wait function instead of an alarm function? I heard it disappeared from game maker 2.
I'm not entirely sure I understand. Are you asking whether or not there is a way to call a script locally in an object, destroy that object, and then have that script run later? If so, I don't think so.

Once you call instance destroy, the object will be destroyed. Any code in that object will cease to run. And effectively all code in GML runs through an object (there are things like room creation code, layer scripts and probably other things I haven't thought of, but they're all for very specific things). So, you can't tell an object to run code later and then destroy it (I believe at the end of the event where instance_destroy is called).
 
Top