GMS 2 [Solved] Scripts in ds_list

Elgarion

Member
Good morning everybody !

I need some help to figure out how to enlist scripts. I tried this :

Code:
//===========  in my first room create
global.My_List = ds_list_create();
ds_list_add(

                global.My_List,

                Scr_Sript1,
                Scr_Sript2,
                Scr_Sript3,

    );
//============ then in another room :

// I find the right script depending of the mission number
var My_mission_number = mission_number ;
var scr_scriptName = ds_list_find_index(global.My_List, My_mission_number-1);

// then I launch  the script
var scriptToCall = asset_get_index(scr_scriptName);
script_execute(scriptToCall);
I get this error : call to non-existent script.

Can someone help me please ? :)

Have a nice day !!!
 

2Dcube

Member
Strange, but the below should work, using the script name directly (no need to get the asset index).
script_execute(scr_scriptName);
 

TsukaYuriko

☄️
Forum Staff
Moderator
You're using ds_list_find_index when you really want ds_list_find_value.
index returns the position of an element in the list.
value returns the element at a position in the list.
(You know the index, you want the value -> you use value)

asset_get_index is also not needed (and will only further break things) as you are already storing asset indices (script resource IDs).
 
Top