1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

script_execute wont work

Discussion in 'Programming' started by OliverSB, Nov 6, 2019.

  1. OliverSB

    OliverSB Member

    Joined:
    Apr 10, 2018
    Posts:
    41
    Why might this be a problem. I have imported an extension and executing any of its scripts like ref_show_message, for example, will simply not work (in my project).

    'ref_show_message("Test")'
    WORKS

    'script_execute(ref_show_message, "Test"))'
    DOESN'T WORK

    Once I delete all scripts and objects from my project (excluding this extension).

    'ref_show_message("Test")'
    WORKS

    'script_execute(ref_show_message, "Test"))'
    WORKS
     
  2. NightFrost

    NightFrost Member

    Joined:
    Jun 24, 2016
    Posts:
    1,977
    You must use asset_get_index to get the index of the asset (in this case, script) for the execute command. In other words,
    Code:
    script_execute(asset_get_index("ref_show_message"), "Test");
    
     
  3. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,602
    That's just not true. If what you said is true, the following would have been mandatory too.
    Code:
    sprite_index = asset_get_index("spr_running");
    Code:
    room_goto(asset_get_index("rm_menu"));
    Code:
    audio_play_sound(asset_get_index("snd_bang"), 1, false);
    The most likely cause is improper index handling by the compiler, which has happened before in tickets like this and this. It should be reported as a bug with a full example.
     
  4. Samuel Venable

    Samuel Venable Time Killer

    Joined:
    Sep 13, 2016
    Posts:
    1,286
    @OliverSB could it be that the function is not an actual script resource? Some extensions don't use scripts to create their functions and instead use the extension editor, which might not be the same mechanism internally.
     
  5. NightFrost

    NightFrost Member

    Joined:
    Jun 24, 2016
    Posts:
    1,977
    Ah, never reply to posts at 3AM right before going to sleep. I'm no sure what I was thinking.
     
  6. OliverSB

    OliverSB Member

    Joined:
    Apr 10, 2018
    Posts:
    41
    FrostyCat's solution works perfect. Only problem now is that I am using an extension that uses the method that doesn't work instead of FrostyCat's method.
     

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