Trouble with timeline_moment_add_script

Discussion in 'Programming' started by Fabseven, Oct 7, 2016.

Tags:
  1. Fabseven

    Fabseven Member

    Joined:
    Oct 7, 2016
    Posts:
    350
    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.
     
  2. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,547
    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);
     
  3. Fabseven

    Fabseven Member

    Joined:
    Oct 7, 2016
    Posts:
    350
    oh my dear thank you hard to believe that's such a mistake can be made !
     
  4. Fabseven

    Fabseven Member

    Joined:
    Oct 7, 2016
    Posts:
    350
    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: Oct 7, 2016
  5. Fabseven

    Fabseven Member

    Joined:
    Oct 7, 2016
    Posts:
    350
    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 !
     
  6. salyossy

    salyossy Member

    Joined:
    Aug 10, 2019
    Posts:
    28

    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: Aug 22, 2019
  7. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,892
    Don't necro 3yr old posts. LOL

    No. All the function does is add a pointer to the script to the timeline, it doesn't add any other code.
     
    ParodyKnaveBob likes this.
  8. salyossy

    salyossy Member

    Joined:
    Aug 10, 2019
    Posts:
    28
    :(

    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:
     
  9. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,547
    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.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice