• 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!

Legacy GM [Solved]Alarm Repeating itself without adding a life

N

nicoltoons

Guest
Good evening,
Please I need help with this. I have gotten alarms to work in the past but I can't seem to get this one to work.

I am trying to create a count down timer that counts to zero and awards the player a life at the end then it counts down again and rewards the player another life at the end etc like candy crush

//Create event
global.secs = 1
global.mins = 5
alarm[0]=30


//Alarm

if global.life <3
{
global.secs-=1
if global.secs == -1
{
global.secs = 59
if global.mins >0
{
global.mins -=1
}
else
{
if global.mins == 0
{
global.life +=1
}
}
}

}
scr_Savegame()
alarm[0]= room_speed

Result : It gives the player a life once and just repeats the count down without awarding a life again.
Help help help!
 
Last edited by a moderator:

Hyomoto

Member
@nicoltoons - Consider the following block:
Code:
if global.seconds -1 == 0 {
  if global.minutes - 1 == 0 {
    global.life +=1 ;
    global.seconds = 60;
    
  } else { global.minutes-- }

  global.seconds = 60;

} else { global.seconds -= 1 }

alarm[0] = room_speed;
I'm not entirely sure what you want to do, but maybe this will help out a little. I assume you are using the alarm as a countdown for each second. However, if that's the case you should be aware you are running your scr_savegame every second and that might be a bit excessive.
 
N

nicoltoons

Guest
@nicoltoons - Consider the following block:
Code:
if global.seconds -1 == 0 {
  if global.minutes - 1 == 0 {
    global.life +=1 ;
    global.seconds = 60;
   
  } else { global.minutes-- }

  global.seconds = 60;

} else { global.seconds -= 1 }

alarm[0] = room_speed;
I'm not entirely sure what you want to do, but maybe this will help out a little. I assume you are using the alarm as a countdown for each second. However, if that's the case you should be aware you are running your scr_savegame every second and that might be a bit excessive.
Thank you. I'll check it out and let you know.
 
N

nicoltoons

Guest
Its not working Hyomoto. It gets to 1m 0secs and counts again.

What I am trying to do is to count down from 5mins to 0mins and give a player a life (global.life +1) at 0 mins then the timer starts counting again from 5 mins. Thanks for looking into this. You're a star
 
N

nicoltoons

Guest
@Hyomoto , you are a star! It's working now; the obj_playerfall object in my game was taking the lives indefinitely because I didn't use a Boolean to ensure that it only did global.life -=1 once. Wow!

This is the code at the end. Thanks again @Hyomoto



if global.life < 3
{
global.secs -=1
if global.secs = -1
{
global.secs =59
if global.mins >0
{
global.mins -=1
}
}

if global.secs == 0 && global.mins == 0
{

global.life += 1
}

alarm[0]=30
}
 
Top