Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- routines.nut
- creator: Ice Flake
- developers: Ice Flake
- for: Innovation fantasy
- description: Client side routines
- license: CLNS
- */
- Routines <- [];
- class Routine
- {
- event = null;
- interval = null;
- repeats = null;
- repeat = null;
- environment = null;
- offset = null;
- constructor (event, interval, repeat = 0, environment = null)
- {
- this.event = event;
- this.interval = interval;
- this.repeats = 0;
- this.repeat = repeat;
- this.environment = environment;
- this.offset = ::Script.GetTicks();
- ::Routines.push(this);
- }
- function Execute()
- {
- if (Script.GetTicks() - this.offset >= this.interval)
- {
- ++this.repeats;
- if (this.repeat != 0 && this.repeats > this.repeat) return this.Destroy();
- this.offset = Script.GetTicks();
- if (this.environment == null) this.event();
- else this.event.acall([this.environment]);
- }
- }
- function Destroy()
- {
- ::Routines.remove(::Routines.find(this));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement