Schedule GMS (v1.0.3)

ScheduleScript | ScheduleAlarm | ScheduleTimeLine
ScheduleEvent | ScheduleEventObject | ScheduleEventUser
ScheduleSound | ScheduleSoundOn | ScheduleSoundAt
SchedulePath |  |
ScheduleNull | ScheduleExists |
ScheduleIsPlaying | ScheduleIsPaused |
ScheduleCancel | SchedulePause | ScheduleResume
ScheduleFinish |  |
Schedule____All | Schedule____Group | Schedule____Target
ScheduleGetTarget | ScheduleGetDelta | ScheduleGetTime
ScheduleGetGroup | ScheduleGetTimeScale | ScheduleGetDuration
ScheduleGetRepeat | ScheduleGetForceCounter | ScheduleGetMute
ScheduleSetTarget | ScheduleSetDelta | ScheduleSetTime
ScheduleSetGroup | ScheduleSetTimeScale | ScheduleSetDuration
ScheduleSetRepeat | ScheduleSetForceCounter | ScheduleSetMute
ScheduleSetTimeScaleAll | ScheduleSetTimeScaleGroup | ScheduleSetTimeScaleTarget
ScheduleDefaultGetTimeScale | ScheduleDefaultSetTimeScale |
SharedSchedulerActivate | SharedSchedulerDestroy |
ScheduleSystemGetEnabled | ScheduleSystemSetEnabled |
ScheduleSystemGetTimeScale | ScheduleSystemSetTimeScale |
ScheduleSystemGetUpdateInterval | ScheduleSystemSetUpdateInterval |
ScheduleSystemClearRoom | ScheduleSystemClearAllRooms |
ScheduleSystemSetMinDeltaFPS | ScheduleSystemCount |

ScheduleScript

Schedules a script to be called after a set duration of time in seconds(delta) or steps

ScheduleScript(target,delta,dur,script,agr0,arg1,...)

target | instance id
delta | selects between seconds(delta) and step timing
dur | amount of time, in seconds or steps, before script is called
script | script resource id
arg0... | optional arguments to pass to script (max: 12)

Returns: schedule

Example:

    schedule = ScheduleScript(id, true, 10, ShowMessage, “Hello!”);

ScheduleAlarm

Overrides the built-in timer system and calls the indicated alarm event after a set duration of time in seconds(delta) or steps

ScheduleAlarm(target,delta,dur,alarm)

target | instance id
delta | selects between seconds(delta) and step timing
dur | amount of time, in seconds or steps, before script is called
alarm | alarm index

Returns: schedule

Example:

    schedule = ScheduleAlarm(id, true, 10, 0);

ScheduleEvent

Schedules a target's event to be called after a set duration of time in seconds(delta) or steps

ScheduleEvent(target,delta,dur,type,numb)

target | instance id
delta | selects between seconds(delta) and step timing
dur | amount of time, in seconds or steps, before event is called
type | type of event to call (e.g. ev_mouse)
numb | event number to call (e.g. ev_left_release)

Returns: schedule

Example:

    schedule = ScheduleEvent(id, false, 30, ev_mouse, ev_left_release);

ScheduleEventObject

Schedules a target to call an event, defined by the designated object, to be called after a set duration of time in seconds(delta) or steps

ScheduleEventObject(target,delta,dur,obj,type,numb)

target | instance id
delta | selects between seconds(delta) and step timing
dur | amount of time, in seconds or steps, before event is called
obj | object index to call event from
type | type of event to call (e.g. ev_mouse)
numb | event number to call (e.g. ev_left_release)

Returns: schedule

Example:

    schedule = ScheduleEventObject(obj_Player, false, 30, obj_Baddie, ev_mouse, ev_left_release);

ScheduleEventUser

Schedules a defined user event to be called after a set duration of time in seconds(delta) or steps

ScheduleEventUser(target,delta,dur,num)

target | instance id
delta | selects between seconds(delta) and step timing
dur | amount of time, in seconds or steps, before event is called
numb | user defined event to call after set time

Returns: schedule

Example:

    schedule = ScheduleEventUser(id, false, 30, 1);

ScheduleSound

Schedules a sound to be played after a set duration of time in seconds(delta) or steps

ScheduleSound(target,delta,dur,sound,priority,loops)

target | instance id
delta | selects between seconds(delta) and step timing
dur | amount of time, in seconds or steps, before event is called
sound | sound resource id
priority | priority of sound playback
loops | whether or not to repeat audio playback

Returns: schedule

Example:

    schedule = ScheduleSound(id, false, 30, snd_GunShot, 0, false);

ScheduleSoundOn

Schedules a sound to be played on the indicated emitter after a set duration of time in seconds(delta) or steps

ScheduleSoundOn(target,delta,dur,emitterid,sound,loops,priority)

target | instance id
delta | selects between seconds(delta) and step timing
dur | amount of time, in seconds or steps, before event is called
emitterid | user defined event to call after set time
sound | sound resource id
loops | whether or not audio playback should repeat
priority | priority of audio playback

Returns: schedule

Example:

    schedule = ScheduleSoundOn(id, false, 30, emitter1, snd_Punch, false, 0);

ScheduleSoundAt

Schedules a sound to played at an indicated position after a set duration of time in seconds(delta) or steps

ScheduleSoundAt(target,delta,dur,sound,x,y,z,falloff_rest_dist,falloff_max_dist,falloff_factor,loops,priority)

target | instance id
delta | selects between seconds(delta) and step timing
dur | amount of time, in seconds or steps, before event is called
sound | sound resource id
x | x position
y | y position
z | z position
falloff_rest_dist | the falloff reference relative to the listener
falloff_max_dist | the maximum falloff distance relative to the listener
falloff_factor | the falloff factor (default 1)
loops | whether or not audio playback should repeat
priority | priority of audio playback

Returns: schedule

Example:

    schedule = ScheduleSoundAt(id, true, 3.75, sndSonar, x-100, y+25, 0, 100, 300, 1, true, 0);

SchedulePath

Schedules a path to be started after a set duration of time in seconds(delta) or steps

SchedulePath(target,delta,dur,path,speed,endaction,absolute)

target | instance id
delta | selects between seconds(delta) and step timing
dur | amount of time, in seconds or steps, before script is called
path | path resource id
speed | speed to follow path in pixels per step
endaction | path endaction constant (see path_start in GM documentation for details)
absolute | follow absolute path or relative path

Returns: schedule

Example:

    schedule = SchedulePath(id, true, 5.0, pathStar, 1.0, 0, false);

ScheduleTimeLine

Schedules a time line to be started after a set duration of time in seconds(delta) or steps

ScheduleTimeLine(target,delta,dur,timeline,loop,speed,position)

target | instance id
delta | selects between seconds(delta) and step timing
dur | amount of time, in seconds or steps, before script is called
timeline | time line resource id
loop | whether or not time line should loop back to start when finished
speed | the speed to play the time line
position | position to start time line at

Returns: schedule

Example:

    schedule = ScheduleTimeLine(id, true, 2.5, tl_Cutscene1, false, 1, 0);

ScheduleNull

Returns a null schedule handle which can be safely called to prevent runtime errors

ScheduleNull()

Returns: null schedule

Example:

    // Create null schedule handle
    schedule = TweenNull();
    // Error won't occur
    TweenCancel(schedule);

ScheduleExists

Checks to see if the indicated schedule is valid

ScheduleExists(schedule)

schedule | schedule handle

Returns: bool

Example:

    if (ScheduleExists(schedule))
    {
        ScheduleCancel(schedule);
    }

ScheduleIsPlaying

Checks to see if the indicated schedule is currently playing

ScheduleIsPlaying(schedule)

schedule | schedule handle

Returns: bool

Example:

    if (ScheduleIsPlaying(schedule))
    {
        SchedulePause(schedule);
    }

ScheduleIsPaused

Checks to see if the indicated schedule is currently paused

ScheduleIsPaused(schedule)

schedule | schedule handle

Returns: bool

Example:

    if (ScheduleIsPaused(schedule))
    {
        ScheduleResume(schedule);
    }

ScheduleCancel

Cancels the indicated schedule

ScheduleCancel(schedule)

schedule | schedule handle

Returns: na

Example:

    schedule = ScheduleScript(id, true, 1, ShowMessage, “Hi”);
    ScheduleCancel(schedule);

SchedulePause

Pauses the indicated schedule

SchedulePause(schedule)

schedule | schedule handle

Returns: na

Example:

    schedule = ScheduleScript(id, true, 1, ShowMessage, “Hi”);
    SchedulePause(schedule);

ScheduleResume

Resumes the indicated schedule

ScheduleResume(schedule)

schedule | schedule handle

Returns: na

Example:

    schedule = ScheduleScript(id, true, 1, ShowMessage, “Hi”);
    SchedulePause(schedule);
    ScheduleResume(schedule);

ScheduleFinish

Immediately finishes the indicated schedule

ScheduleFinish(schedule)

schedule | schedule handle

Returns: na

Example:

    // Schedule showing of message
    schedule = ScheduleScript(id, true, 1, ShowMessage, “Hi”);
    // Have message show right away
    ScheduleFinish(schedule);

Schedule____All

Affects all active schedules in the current room

Schedule____All(deactivated)

deactivated | affect schedules belonging to deactivated targets?

Returns: na

    Example:
    SchedulePauseAll(); // Pause all active schedules in room
    ScheduleResumeAll(); // Resume all paused schedules in room

Schedule____Group

Affects all active schedules assigned to indicated group

Schedule____Group(group,deactivated)

group | schedule group
deactivated | affect schedules belonging to deactivated targets?

Returns: na

Example:

    SchedulePauseGroup(1); // Pause all active schedules assigned to group
    ScheduleResumeAll(1); // Resume all paused schedules assigned to group

Schedule____Target

Affects all active schedules assigned to indicated target instance

Schedule____Target(target)

target | instance id

Returns: na

Example:

    SchedulePauseTarget(npc1) // Pause all active schedules assigned to target instance
    ScheduleResumeTarget(npc1) // Resume all paused schedules assigned to target instance

ScheduleGetTarget

Returns the target instance associated with the schedule

ScheduleGetTarget(schedule)

schedule | schedule handle

Returns: instance

Example:

    instance = ScheduleGetTarget(schedule);

ScheduleGetDelta

Returns whether or not the schedule uses delta/seconds or frames/steps timing

ScheduleGetDelta(schedule)

schedule | schedule handle

Returns: bool

Example:

    uses_seconds = ScheduleGetDelta(schedule);

ScheduleGetTime

Returns a schedules remaining time

ScheduleGetTime(schedule)

schedule | schedule handle

Returns: real

Example:

    time_remaining = ScheduleGetTime(schedule);

ScheduleGetGroup

Returns the group the schedule is associated with

ScheduleGetGroup(schedule)

schedule | schedule handle

Returns: real

Example:

    group = ScheduleGetGroup(schedule);

ScheduleGetTimeScale

Returns the time scale of the indicated schedule

ScheduleGetTimeScale(schedule)

schedule | schedule handle

Returns: real

Example:

    timer_scale = ScheduleGetTimeScale(schedule);

ScheduleGetDuration

Returns the full duration of the schedule

ScheduleGetDuration(schedule)

schedule | schedule handle

Returns: real

Example:

    duration = ScheduleGetDuration(schedule);

ScheduleGetRepeat

Returns the remaining number of times the schedule is set to repeat

ScheduleGetRepeat(schedule)

schedule | schedule handle

Returns: real

Example:

    repeat_count = ScheduleGetRepeat(schedule);

ScheduleGetForceCounter

Returns whether or not the counter is forced to run even if target instance is deactivated

ScheduleGetForceCounter(schedule)

schedule | schedule handle

Returns: real

Example:

    counter_forced = ScheduleGetForceCounter(schedule);

ScheduleGetMute

Returns whether or not a schedule's callback is muted and not be executed

ScheduleGetMute(schedule)

schedule | schedule handle

Returns: real

Example:

    callback_muted = ScheduleGetMute(schedule);

ScheduleDefaultGetTimeScale

Returns the default time scale assigned to newly created schedules

ScheduleDefaultGetTimeScale()

Returns: real

Example:

    def_scale = ScheduleDefaultGetTimeScale();

ScheduleSetTarget

Assigns a new target instance to associate with the indicated schedule

ScheduleSetTarget(schedule,target)

schedule | schedule handle
target | instance id

Returns: na

Example:

    ScheduleSetTarget(schedule, other);

ScheduleSetDelta

Toggles indicated schedule to use delta/seconds or steps/frames timing

ScheduleSetDelta(schedule,delta)

schedule | schedule handle
delta | use seconds?

Returns: na

Example:

    ScheduleSetDelta(schedule, false); // Set schedule to use step timing

ScheduleSetTime

Updates schedule's remaining time to the indicated value

ScheduleSetTime(schedule,time)

schedule | schedule handle
time | time in seconds(delta) or steps

Returns: na

Example:

    ScheduleSetTime(schedule, 2.0); // Set schedule to 2 seconds

ScheduleSetGroup

Assigns a schedule to the indicated group

ScheduleSetGroup(schedule,group)

schedule | schedule handle
group | schedule group

Returns: na

Example:

    ScheduleSetGroup(schedule, 2);

ScheduleSetDuration

Sets the full duration of a schedule – useful for updating repeated schedule duration (does not effect current time value)

ScheduleSetDuration(schedule,dur)

schedule | schedule handle
dur | schedule duration

Returns: na

Example:

    schedule = Schedule(id, true, 5, ShowMessage, “Such a hoser, eh?”);
    ScheduleSetRepeat(schedule, 10); // repeat 10 times
    ScheduleSetDuration(schedule, 2); // change schedule duration

ScheduleSetRepeat

Sets the number of the times the schedule is to repeat – Setting count to '-1' will have the schedule repeat forever

ScheduleSetRepeat(schedule,count)

schedule | schedule handle
count | number of times to repeat schedule

Returns: na

Example:

    schedule = Schedule(id, true, 5, ShowMessage, “Hockey is great, eh?”);
    ScheduleSetRepeat(schedule, 2); // Repeat scheduled message 2 times
    ScheduleSetRepeat(schedule, -1) // I changed my mind. Let's repeat it forever!

ScheduleSetForceCounter

Used to force schedule timer to count down even when target instance is deactivated

! Be aware that callbacks WILL NOT execute for deactivated target instances !

ScheduleSetForceCounter(schedule,force)

schedule | schedule handle
force | force counter to continue if target deactivated?

Returns: na

Example:

    schedule = Schedule(id, true, 5, ShowMessage, “Bam!”);
    ScheduleSetForceCounter(schedule, true); // counter will continue if instance deactivated
    instance_deactivate_object(id);

ScheduleSetMute

Toggles whether or not a schedule's callback should be suppressed and not executed

ScheduleSetMute(schedule,mute)

schedule | schedule handle
mute | suppress schedules callback?

Returns: na

Example:

    ScheduleSetMute(schedule, true); // Script or event will not be executed

ScheduleSetTimeScale

Changes the time scale for the indicated schedule

ScheduleSetTimeScale(schedule,scale)

schedule | schedule handle
scale | time scale

Returns: na

Example:

    ScheduleSetTimeScale(schedule, 0.5); // Schedule will run at half speed

ScheduleSetTimeScaleAll

Changes the time scale for the indicated schedule

ScheduleSetTimeScaleAll(scale,deactivated)

scale | time scale
deactivated | affect schedules belonging to deactived targets?

Returns: na

Example:

    ScheduleSetTimeScaleAll(0.5, true); // Set all schedules, including deactivated, to run at half speed

ScheduleSetTimeScaleGroup

Changes the time scale for the indicated schedule

ScheduleSetTimeScaleGroup(group,scale,deactivated)

group | schedule group
scale | time scale
deactivated | affect schedules belonging to deactived targets?

Returns: na

Example:

    ScheduleSetTimeScaleGroup(1, 2, false); // Set schedules belonging to group, except deactivated, to run at double speed

ScheduleSetTimeScaleTarget

Changes the time scale for the indicated schedule

ScheduleSetTimeScaleTarget(target,scale)

target | instance id
scale | time scale

Returns: na

Example:

    ScheduleSetTimeScaleTarget(id, 0.5); // Target schedules will run at half speed

ScheduleDefaultSetTimeScale

Sets the default time scale assigned to newly created schedules

ScheduleDefaultSetTimeScale(scale)

scale | time scale

Returns: na

Example:

    ScheduleDefaultSetTimeScale(0.5); // Have new schedules run at half speed

ScheduleSetTimeTarget

Changes the time scale for the indicated schedule

ScheduleSetTimeScale(target,scale)

target | instance id
scale | time scale

Returns: na

Example:

    ScheduleSetTimeScale(schedule, 0.5); // Schedule will run at half speed

SharedSchedulerActivate

Activates the shared scheduler – use in case of scheduler instance being deactivated

SharedSchedulerActivate()

Returns: na

Example:

    instance_deactivate_all(true);
    SharedSchedulerActivate();

SharedSchedulerDestroy

Destroys the shared scheduler instance, effectively destroying the scheduling system

SharedSchedulerDestroy()

Returns: na

Example:

    SharedSchedulerDestroy();

ScheduleSystemGetEnabled

Returns whether or not the scheduling system is active

ScheduleSystemGetEnabled()

Returns: bool

Example:

    isActive = ScheduleSystemGetEnabled();

ScheduleSystemGetTimeScale

Returns the global time scale of the scheduling system

ScheduleSystemGetTimeScale()

Returns: real

Example:

    system_time_scale = ScheduleSystemGetTimeScale);

ScheduleSystemGetUpdateInterval

Returns the update interval of the scheduling system

ScheduleSystemGetUpdateInterval()

Returns: real

Example:

    interval = ScheduleSystemGetUpdateInterval();

ScheduleSystemSetEnabled

Toggles the active state of the scheduling system

ScheduleSystemSetEnabled(enabled)

enabled | system is active?

Returns: na

Example:

    ScheduleSystemSetEnabled(false) // Disable scheduling system

ScheduleSystemSetTimeScale

Sets the global time scale of the scheduling system – Effects all schedules (default: 1.0)

ScheduleSystemSetTimeScale(scale)

scale | time scale

Returns: na

Example:

    ScheduleSystemSetTimeScale(2.0); // Double speed of all schedules

ScheduleSystemSetUpdateInterval

Sets the update interval of the scheduling system (default: 1)

ScheduleSystemSetUpdateInterval(interval)

interval | number of steps before each system update

Returns: na

Example:

    ScheduleSystemSetUpdateInterval(2); // Update system every 2 steps (runs at half speed)

ScheduleSystemSetMinDeltaFPS

Sets the minimum frame rate before delta time schedules start to lag behind step game logic (default: 10)

ScheduleSystemSetMinDeltaFPS(fps)

fps | minimum target frame rate

Returns: na

Example:

    ScheduleSystemSetMinDeltaFPS(5); // Delta schedules will lag behind if fps drops below 5

ScheduleSystemClearRoom

Clears schedules belonging to instances within an inactive persistent room

ScheduleSystemClearRoom(room)

room | persistent room id

Returns: na

Example:

    ScheduleSystemClearRoom(rm_PauseMenu) // Destroy schedules belonging to pause menu room

ScheduleSystemClearAllRooms

Clears schedules belonging to instances within all inactive persistent rooms

ScheduleSystemClearAllRooms()

Returns: na

Example:

    ScheduleSystemClearAllRoom() // Destroy schedules in all inactive persistent rooms

ScheduleSystemCount

Returns the current number of schedules in the system

ScheduleSystemCount()

Returns: real

Example:

    numSchedules = ScheduleSystemCount();