time_source_reconfigure

This function is used to modify the core properties of a Time Source, without having to create an entirely new one.

You specify an existing Time Source, and then set the properties that are also set in time_source_create(), except the parent. Read that page for detailed information on these properties.

The specified Time Source will be reset and deactivated, and will need to be started again.

 

Syntax:

time_source_reconfigure(id, period, units, callback, [args, repetitions, expiry_type]);

ArgumentTypeDescription
idTime SourceThe Time Source to reconfigure
periodRealThe period that the Time Source runs for, in the given units
unitsTime Source Unit ConstantThe units that the given period is in
callbackMethodThe method to call when the Time Source expires
argsArrayOPTIONAL An array containing the arguments to pass into the method
repetitionsRealOPTIONAL The number of times the Time Source should repeat, or -1 for indefinite repetition
expiry_typeTime Source Expiry ConstantOPTIONAL Whether the Time Source expires on the frame nearest to its expiry, or on the next frame

 

Returns:

N/A

 

Example:

function change_spawn_delay(new_delay)
{
    time_source_reconfigure(obj_game.spawn_time_source, new_delay, time_source_units_frames, obj_game.spawn_method, [], -1);
    time_source_start(obj_game.spawn_time_source);
}

This creates a new function that changes the spawn delay used for in-game enemies.

Assuming the game uses a Time Source called obj_game.spawn_time_source to spawn enemies, that Time Source will need to be updated once the spawn delay changes.

This function does exactly that, reconfiguring the Time Source with the new delay and then starting it again.