script_execute wont work

OliverSB

Member
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
 

NightFrost

Member
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");
 

FrostyCat

Redemption Seeker
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");
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.
 
S

Sam (Deleted User)

Guest
@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.
 

OliverSB

Member
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.
 
Top