With this function you can dynamically add a script function to Timelines at any given "moment" within that time line, where a "moment" is the equivalent of one game tick (or step). In this way you can create a new time line using the timeline_add() function and add different behaviours at any point, or simply modify a previously created time line resource with new behaviours. Note that the function cannot require any additional arguments when using this function, and if you use it to modify a Timeline asset present in the Asset Brower, then all insatnces that use this timeline will be affected, and the change will last until the end of the game (calling game_restart() will not reset the change either).
timeline_moment_add_script(ind, step, script);
| Argument | Description |
|---|---|
| ind | The index of the time line to add a moment to. |
| step | The moment (step) to add to. |
| script | The index of the script function to add into the moment. |
N/A
global.tl = timeline_add();
var i = room_speed * 60;
repeat(3)
{
timeline_moment_add_script(global.tl, i, choose(Attack_1, Attack_2, Attack_3);
i += room_speed * 60;
}
The above code will create a new time line and store its index in the variable "global.tl". It will then add three scripts to the time line, chosen at random, at one minute intervals.