Advertisement
RefresherTowel

Custom Alarms

May 11th, 2018
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ///CREATE EVENT
  2. //Initialises the number of alarms you would like
  3. for (var i=0;i<max_alarms;i++) {
  4.     timer[i,0] = -1;
  5. }
  6.  
  7. ///STEP EVENT
  8. //Cycle through the alarms decrementing them by one and executing the stored script when an alarm hits 0
  9. for (var i=0;i<max_alarms;i++) {
  10.     if (timer[i,0] > -1) {
  11.         timer[i,0]--;
  12.     }
  13.     if (timer[i,0] == 0) {
  14.         script_execute(timer[i,1]);
  15.     }
  16. }
  17.  
  18. ///set_timer(time,script)
  19. ///SET TIMER SCRIPT
  20. //Call this script to set an alarm. It finds an unused alarm, sets it to the time you want and stores the script that should be executed when the alarm fires
  21.  
  22. var set = false
  23. for (var i=0;i<max_alarms;i++) {
  24.     if (!set) {
  25.         if (timer[i,0] == -1) {
  26.             timer[i,0] = argument0;
  27.             timer[i,1] = argument1;
  28.             set = !set;
  29.         }
  30.     }
  31.     else {
  32.         return set;
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement