• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker [Solved] Scripts in ds_list

E

Elgarion

Guest
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