GameMaker: Studio

GameMaker: Studio

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
< >
Показані коментарі 115 із 27
Pretty sure when you use a comment you use // not ///
Цитата допису DarkHedgie:
Pretty sure when you use a comment you use // not ///

/// Sets a comment for the event
If it's something you want to repeat indefinitely, just reset it at the bottom of your alarm event code.
Цитата допису Thew:
If it's something you want to repeat indefinitely, just reset it at the bottom of your alarm event code.
How?
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.
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.)
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
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;
}
Автор останньої редакції: CatBoyJonah; 19 квіт. 2015 о 18:13
Цитата допису 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
Цитата допису 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
Цитата допису 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 :/
Цитата допису 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
Can you post the code pertaining to the alarm, separated by event (create, step, draw, alarm)? It's probably a simple mistake.
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.
Цитата допису 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
< >
Показані коментарі 115 із 27
На сторінку: 1530 50