Trouble with timeline_moment_add_script

Fabseven

Member
Hello there,

I have got trouble with timeline_moment_add_script,
I created an empty timeline named timeline0
And with this code :


Code:
                var step = 0
                repeat(10)
                {
                    
                    timeline_moment_add_script(timeline0,step,system_popmonster())
                    step += 100
                }
                timeline_index = timeline0
                timeline_running = true
                timeline_speed = 1   
                timeline_position =  0
I am trying to make my game pop monster each 100 step but instead all the 10 monsters a created at step 0.

Code:
script system_popmonster() 

   instance_create(0,0, obj_monster)
Why ?!

It works when i create a timeline with the editor but i want to create one with code.
 

FrostyCat

Member
Get rid of the () to turn the script call (which runs it) back into a script reference (which doesn't).
Code:
timeline_moment_add_script(timeline0, step, system_popmonster);
 

Fabseven

Member
argh still not working
Code:
 global.tlatk = timeline_add()
                var step = 0
                repeat(10)
                {
                   
                    timeline_moment_add_script(global.tlatk,step,system_popmonster)
                    step += 100
                }
                timeline_index = global.tlatk
                timeline_running = true
                timeline_speed = 1  
                timeline_position =  0
10 monsters at step 0...
timeline_max_moment returns 0
but timeline_size returns 10 ...
 
Last edited:

Fabseven

Member
Seems to be a bug http://bugs.yoyogames.com/view.php?id=15625
not corrected but there is a solution https://www.reddit.com/r/gamemaker/...ne_moment_add_script/?st=iu07n4hy&sh=7171b9f1
you have to fill the timeline at the end, so the right code is this :

Code:
 global.tlatk = timeline_add()
                var step = 1000
                repeat(10)
                {
                    
                    timeline_moment_add_script(global.tlatk,step,system_popmonster)
                    step -= 100
                }
                timeline_index = global.tlatk
                timeline_running = true
                timeline_speed = 1   
                timeline_position =  0
working fine !
 

salyossy

Member
Get rid of the () to turn the script call (which runs it) back into a script reference (which doesn't).

Code:
timeline_moment_add_script(timeline0, step, system_popmonster());
adds the script to the timeline and runs it

while:
Code:
timeline_moment_add_script(timeline0, step, system_popmonster);
adds the script to the timeline without running it.


but, in my project, i need to add a script that gets parameters. And then it runs the script against my will.

Is there a way to add script with parameters, without running it???

EDIT: ooops, "Note that the script cannot require any additional arguments when using this function."

PLIZZ i need to edit timeline through code, is there any way to manipulate it to execute scripts with arguments??
 
Last edited:

FrostyCat

Member
:(

I've been told not to run and start new threads,
and,to prove that i tried my best to find a solution before even thinking about posting...

AND SO I DID :oops::rolleyes:
Nobody told you not to start new topics, but you have been told not to bump up old topics. So stop bringing back old topics.

Start your own topics for your own questions. If you want to show what other posts you've looked at, link to them instead of replying to them.
 
Top