Asset - Scripts [TIMERS] xScheduler is yet another (advanced) timer system (FREE)


xScheduler (marketplace)

xScheduler (


xScheduler (code).jpg


This is yet another task scheduler (advanced timers) system asset for GMS2.3+


1) You need to instantiate a Scheduler, using the following code:

scheduler = new Scheduler();
2) Schedule a event to be executed after an amount of time, X seconds...

myEvent = scheduler.scheduleOnce(function() { show_debug_message("Done"); }, 3.5);
3) Finally during step event we need to call the scheduler update method (passing the delta_time constant).

4) Run the game and after 3.5 seconds you should see the message "Done" printed to the terminal.


This library provides a set of useful function that you can use to create time based (fps independent) events.

scheduler = new Scheduler();

scheduler.resume() // Will resume the scheduler if it was paused
scheduler.pause() // Will pause the scheduler if it is running
scheduler.update(delta_time) // Updates the scheduler
event = scheduler.scheduleOnce(callback, timeout) // Schedules an event with a callback function with a given delay.
event = scheduler.scheduleInterval(callback, timeout) // Schedules a looping event with a callback function with a given delay.
trigger = scheduler.createTrigger(callback, timeout, loop, releaseRef) // Creates a trigger for scheduling events (*)
event = scheduler.unschedule(event/method, all?) // Unschedule a given event or a given method (optional all flag)
(*) The createTrigger method should be highlighted since it provides a powerful way of scheduling events. This method returns a trigger and this trigger can be called as a method for automatic event scheduling.
This feature allows for creating more decoupled code, ie.: an instance can be given a trigger that it just needs to call without the need to be referencing another instance variables. See code below:

trigger = scheduler.createTrigger(callback, timeout, loop, releaseRef)
event = trigger(); // Triggers the schedule of the event.

//Trigger is duplicate safe, meaning that consecutive calls will NOT schedule multiple events.
trigger(); // This won't schedule the event again until it has occurred
The event instance itself provides a set of utility functions that can be used to manipulate the event after it was scheduled:

event.cancel() // Cancels the current scheduled event
event.isScheduled() // Returns true if the event is schedule to execute
event.getCallback() // Returns the callback method associated with the event
All the code is fully documented as always with my assets, so you shouldn't have any problems following along and understanding the implementation.


The demo project serves as an example for the Scheduler system and all its code is inside the Demo folder of the asset pack. You don't need to include it to use the asset.


The asset is fully compatible with GMS2.3+ and is purely written in GML making it compatible with all exports available.
Last edited: