GameMaker: Studio

GameMaker: Studio

Ver estadísticas:
benjie03 19 ABR 2015 a las 4:34 a. m.
Alarm Reset
Hey!

How do I reset a alarm after it has happened? I've tried ///Alarm Reset
if alarm[1] = 0
{
alarm[1] = 30
}

and that didnt work
< >
Mostrando 1-15 de 27 comentarios
Lockehead 19 ABR 2015 a las 6:04 a. m. 
Pretty sure when you use a comment you use // not ///
benjie03 19 ABR 2015 a las 6:13 a. m. 
Publicado originalmente por DarkHedgie:
Pretty sure when you use a comment you use // not ///

/// Sets a comment for the event
Thew 19 ABR 2015 a las 7:21 a. m. 
If it's something you want to repeat indefinitely, just reset it at the bottom of your alarm event code.
benjie03 19 ABR 2015 a las 7:56 a. m. 
Publicado originalmente por Thew:
If it's something you want to repeat indefinitely, just reset it at the bottom of your alarm event code.
How?
Thew 19 ABR 2015 a las 9:34 a. m. 
If you want alarm[1] to fire every 30 steps, write alarm[1] = 30; into the create event. Then in the alarm[1] event you'll also want to write alarm[1] = 30;

That way it'll reset itself each time the alarm fires.
Sera 19 ABR 2015 a las 2:06 p. m. 
As best I've ever gotten GM to inform me, trying to get feedback values FROM an alarm is routinely unsuccessful; your if alarm[1] = 0 statement is probably failing because of how GM handles the things more than anything else. If you want to time things out based on the value of a timer, you're better off creating a variable and handling its countdown manually by decreasing its value every step.

Otherwise, like others have stated, just reset your alarm in the alarm event itself; setting an alarm value anywhere else totally resets the countdown (which in the event your if statement is working, might be resetting the alarm value before the actual alarm event is ever fired, thus preventing GM's internal checks from ever determining the alarm to be set off.)
Blind 19 ABR 2015 a las 3:48 p. m. 
Ya, Alarms are calculated after the begin step, but before the main step (keyboard and mouse events are in between as well)

As such, adjusting an alarm during the wrong phase won't work at all.

As an aside: You can always draw_text(x,y-8,string(alarm[0]) or something... to moniter your alarm status
CatBoyJonah 19 ABR 2015 a las 6:13 p. m. 
if alarm[1] = 0
{
alarm[1] = 30
}

This code is saying that as soon as the alarm goes off, set it back to 30. This will work, but you will have to put it AFTER all the other events in the alarm code. what you want to do is reset it after it is done. when the alarm finishes all the code in the event, the alarm is then set to -1. So to reset the alarm, you write;
i alarm[1] = -1
{
alarm[1] = 30;
}
or
if alarm[1] <= 0
{
alarm[1] = 30;
}
Última edición por CatBoyJonah; 19 ABR 2015 a las 6:13 p. m.
benjie03 20 ABR 2015 a las 1:51 a. m. 
Publicado originalmente por iamepic215:
if alarm[1] = 0
{
alarm[1] = 30
}

This code is saying that as soon as the alarm goes off, set it back to 30. This will work, but you will have to put it AFTER all the other events in the alarm code. what you want to do is reset it after it is done. when the alarm finishes all the code in the event, the alarm is then set to -1. So to reset the alarm, you write;
i alarm[1] = -1
{
alarm[1] = 30;
}
or
if alarm[1] <= 0
{
alarm[1] = 30;
}
I tried them first, they didn't work
benjie03 20 ABR 2015 a las 1:51 a. m. 
Publicado originalmente por Zaron X:
As best I've ever gotten GM to inform me, trying to get feedback values FROM an alarm is routinely unsuccessful; your if alarm[1] = 0 statement is probably failing because of how GM handles the things more than anything else. If you want to time things out based on the value of a timer, you're better off creating a variable and handling its countdown manually by decreasing its value every step.

Otherwise, like others have stated, just reset your alarm in the alarm event itself; setting an alarm value anywhere else totally resets the countdown (which in the event your if statement is working, might be resetting the alarm value before the actual alarm event is ever fired, thus preventing GM's internal checks from ever determining the alarm to be set off.)

Thank you everyone
benjie03 20 ABR 2015 a las 2:02 a. m. 
Publicado originalmente por Thew:
If you want alarm[1] to fire every 30 steps, write alarm[1] = 30; into the create event. Then in the alarm[1] event you'll also want to write alarm[1] = 30;

That way it'll reset itself each time the alarm fires.
That won't work :/
benjie03 20 ABR 2015 a las 2:03 a. m. 
Publicado originalmente por BBX:
Ya, Alarms are calculated after the begin step, but before the main step (keyboard and mouse events are in between as well)

As such, adjusting an alarm during the wrong phase won't work at all.

As an aside: You can always draw_text(x,y-8,string(alarm[0]) or something... to moniter your alarm status

The alarm moniter works, it stays on -1 all the time
Thew 20 ABR 2015 a las 7:06 a. m. 
Can you post the code pertaining to the alarm, separated by event (create, step, draw, alarm)? It's probably a simple mistake.
Blind 20 ABR 2015 a las 8:52 a. m. 
An alarm of -1 means it's never being intially set. An active alarm, even if delayed by... MAGIC, will be at 0 until it triggers.

-1 means the alarm is completely off.
benjie03 21 ABR 2015 a las 10:11 a. m. 
Publicado originalmente por BBX:
An alarm of -1 means it's never being intially set. An active alarm, even if delayed by... MAGIC, will be at 0 until it triggers.

-1 means the alarm is completely off.
How do I get it set then, on the create code i've got alarm[1] = 30
< >
Mostrando 1-15 de 27 comentarios
Por página: 1530 50