Alarm not working in step event? [DND]

L

leontas2007

Guest
Hello!

I am trying to make a variable get +1 for every miner_number(var) for every second. I have a step event and inside it I have set alarm for every second (60 frames). The problem is that the alarm is never activated and this is only happening in the step event.

Did I do something wrong? is there an other way around it?

Screenshot_1.pngScreenshot_2.png
 

Simon Gust

Member
The step event is run every frame, so your alarm is also reset every frame, it has no chance to reach 0.
You can start the alarm in the create event and have itself reset in it's own alarm event.
 
L

leontas2007

Guest
The step event is run every frame, so your alarm is also reset every frame, it has no chance to reach 0.
You can start the alarm in the create event and have itself reset in it's own alarm event.
At last it's working! Thank you very much. I saw many different topics on count down events, but everything was in gml.

[edit] well It kinda works. The problem now is that when I do the upgrade, I want to make the alarm start. So I have "if" miner_number(variable) is equal or greater to 1, to make the alarm start. The problem is that it never starts because it is in the create event.

[edit2] I fixed it by having the "if" inside the alarm 0, so it starts working with create and reset again and again until miner_number is at least 1.
 
Last edited by a moderator:

Chourando

Member
I suggest to put "if" in STEP event to activate alarm and use some kind of trigger to prevent activating it until alarm takes actions:
GML:
//STEP EVENT
if(trigger)  // could be more logic by your needs (Jupiter && Mars in same row etc.)
{
    alarm[0] = frames;  // time until alarm
    trigger = false;    // forbid to activate alarm
}

//ALARM 0
//do some action
trigger = true;    // allow to set alarm
 
The step event is run every frame, so your alarm is also reset every frame, it has no chance to reach 0.
You can start the alarm in the create event and have itself reset in it's own alarm event.
what to do if u want to activate alarm event in step event once when something else happens
 
Top