Advertisement
Guest User

Client-side routines

a guest
May 12th, 2017
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.23 KB | None | 0 0
  1. /*
  2.     routines.nut
  3.    
  4.     creator:     Ice Flake
  5.     developers:  Ice Flake
  6.     for:         Innovation fantasy
  7.     description: Client side routines
  8.     license:     CLNS
  9. */
  10.  
  11. Routines <- [];
  12.  
  13. class Routine
  14. {
  15.     event          = null;
  16.     interval       = null;
  17.     repeats        = null;
  18.     repeat         = null;
  19.     environment    = null;
  20.  
  21.     offset         = null;
  22.  
  23.     constructor (event, interval, repeat = 0, environment = null)
  24.     {
  25.         this.event          = event;
  26.         this.interval       = interval;
  27.         this.repeats        = 0;
  28.         this.repeat         = repeat;
  29.         this.environment    = environment;
  30.  
  31.         this.offset         = ::Script.GetTicks();
  32.  
  33.         ::Routines.push(this);
  34.     }
  35.  
  36.     function Execute()
  37.     {
  38.         if (Script.GetTicks() - this.offset >= this.interval)
  39.         {
  40.             ++this.repeats;
  41.  
  42.             if (this.repeat != 0 && this.repeats > this.repeat) return this.Destroy();
  43.  
  44.             this.offset = Script.GetTicks();
  45.             if (this.environment == null) this.event();
  46.             else this.event.acall([this.environment]);
  47.         }
  48.     }
  49.  
  50.     function Destroy()
  51.     {
  52.         ::Routines.remove(::Routines.find(this));
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement