• Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!

GML alarm_set not working

Hmm, I have never tried using alarm_set, what does alarm[0] = 260 do? Are you certain room_restart isn't running, and it is just hitting a loop or something? Maybe try show_message(1); instead and see if that pops up anything.

*edit - and a few things that could stop an alarm are things like destroying the object calling the alarm, or if you have another event setting/clearing the alarm without realizing it. For more debugging you can also run alarm_get(i) in something like the step event and see what the alarm is doing exactly.
 

Unarthadox

Member
Hmm, I have never tried using alarm_set, what does alarm[0] = 260 do? Are you certain room_restart isn't running, and it is just hitting a loop or something? Maybe try show_message(1); instead and see if that pops up anything.

*edit - and a few things that could stop an alarm are things like destroying the object calling the alarm, or if you have another event setting/clearing the alarm without realizing it. For more debugging you can also run alarm_get(i) in something like the step event and see what the alarm is doing exactly.
kinda new to gamemaker so i dont know what any of this means, but basically, alarm_set makes a timer for an alarm to go off, basically what i'm trying to do is make a certain number of seconds and then alarm 0 will do whatever is in it (for in this case, restart the room.)

edit: something's probably looping the alarm since on certain times, lets say 50 will work but 75 will not.
 
What is your room_speed? Setting an alarm to go off after 260 steps with a room speed of 30 would mean it would take a little over 8 seconds for the alarm to go off. Perhaps you aren't waiting long enough to see the alarm reach 0??

Steps to seconds are always calculated as # number of steps/ room_speed
 

Unarthadox

Member
What is your room_speed? Setting an alarm to go off after 260 steps with a room speed of 30 would mean it would take a little over 8 seconds for the alarm to go off. Perhaps you aren't waiting long enough to see the alarm reach 0??

Steps to seconds are always calculated as # number of steps/ room_speed
i've waited there for about 3 minutes, and i don't know how to check my room speed.
 
i've waited there for about 3 minutes, and i don't know how to check my room speed.
You set your room speed in the room editor. Also, if nothing in your room changes at all before that alarm ends (moving the player around, enemies moving around, etc.) then you won't notice a change because the restart is instantaneous.

EDIT: If it still isn't working, try putting the alarm in a step event and check to make sure the alarm isn't already set before setting it:

Code:
if alarm[0] == -1{
alarm_set(0,260);
}
 

TailBit

Member
Is a instance of the object in the room?

You can also tell it to draw the alarm value so you know when it should go off:

draw event:
Code:
// so it still draw itself when draw event is active

draw_self()

draw_text(x+64,y, string(alarm[0]) )
 
Here is an idea, make a totally new object and place it in your room. In the create event put

alarm[0] = 260;

and then in the alarm[0] event put this

show_message("Success");

Run the game, see if it puts up a message. If it produces an alert box then that likely means whatever object you are calling the alarm from is either being destroyed before the alarm triggers or you are accidentally clearing/resetting it without realizing. To debug that you need to put show_debug_message(get_alarm(0)); in the step event of whatever object you are trying to trigger that alarm on. Run the game and look at the output console (should be streaming a bunch of numbers) this should tell you what the alarm is currently set to. You need to see if it's going up and resetting, or if its being cleared, or what exactly.
 
Can you show what code you have in your Animation End event? That's the only event you have not shown us, and if you happen to be destroying the instance in there then that may be happening before alarm has time to count down. That could also be why you have found that using 50 for you alarm works (as that might be just under 1 second if you have a room speed of 60) and the animation might take just slightly over that, but 75 on the alarm would be happening after the animation has ended and the instance has been destroyed.

I'm just guessing, but if you could show that event code it might help.
 
Top