alarm

Sets an alarm for the instance.

Syntax:

alarm[0 ... 11]


Returns: Real.


Description

This 1 dimension array is used to get the current value for any alarms that the instance may have, or to set those alarms. There are twelve alarms built into each instance of an object, and each one has its own event that will run when this variable reaches 0. it should be noted that the alarm is not finished at that point (although the event has been triggered) as the next step it will go down to -1, so if you need to stop an alarm for any reason you should set its array value to -1 not 0. Alarm times are calculated in game steps, with a value of 30 being 30 steps etc...

NOTE: An alarm with no actions or code in it will not run. However, even with just a comment and no code, the alarm will count down.

You can set the alarm array directly (and retrieve the current alarm value directly by using the array too), but under some circumstances this is not the most appropriate method, so you can also use the function alarm_set() to set an alarm, and the function alarm_get() to get the value of an alarm.


Example:

if canshoot
   {
   if keyboard_check_pressed(vk_space)
      {
      canshoot = false;
      alarm[0] = room_speed;
      instance_create(x, y, obj_Bullet);
      }
   }

The above code checks a variable and then if it is true, checks for a key press and if that is true it finally sets the variable to false, sets an alarm (where it will be set to true again) and creates an instance.


Back: Instance Properties
Next: object_index
© Copyright YoYo Games Ltd. 2018 All Rights Reserved