• 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 Having a lot of trouble with alarms.

J

JakeW

Guest
I really do not understand alarms at all, or why the code I have isn't working.

What I have in the create event is,

alarm[0] = 0;


and then in the step event

if(alarm[0] = 0) {
show_message("test");
alarm[0] = room_speed * 7;
}


Why does this not work?
 
I

icuurd12b42

Guest
add a comment in the alarm0 event, else it wont tick down
 

YoSniper

Member
Alarms are quirky and I rarely use them. I prefer to instantiate my own timer variables.

That said, in my experience, alarms only work as positive values. They count down to zero (or -1?), at which point they become disabled.

Try changing if alarm[0] = 0 to if alarm[0] <= 0 and see if that works.

[EDIT] Or do what that guy said.
 
I

icuurd12b42

Guest
alarms trigger at 0 and stop ticking at -1...

GM has an optimization to not execute events that have no code/d&d, as such if the alarm event has nothing in it, it will not be processed.

A code box with a //comment line
or a Comment D&D will make it tick
 
J

JakeW

Guest
Alarms are quirky and I rarely use them. I prefer to instantiate my own timer variables.

That said, in my experience, alarms only work as positive values. They count down to zero (or -1?), at which point they become disabled.

Try changing if alarm[0] = 0 to if alarm[0] <= 0 and see if that works.

[EDIT] Or do what that guy said.
Yeah I'm not too fond of alarms. How do I make my own timer variables?
 

YoSniper

Member
Create Event
Code:
my_timer = 0;
Step Event
Code:
if my_timer > 0 {
    my_timer -= 1;
} else {
    show_message("Test");
    my_timer = 7 * room_speed;
}
Similar to that, to imitate your original test code.
 
I

icuurd12b42

Guest
simplest form:
my_timer--;
if(my_timer == 0)
{
triggered();
}
 

Bentley

Member
Is it because alarms always tick down to -1 when higher than -1. So when you set it to 0 in the create, it ticks down to -1 before the line that checks if the alarm is at 0 runs? Just a guess.
 
Top