S
SmashAdams
Guest
So I have an object (obj_weapon_gui)
and in that object's create event, I've created a ds_list named SHOTGUN, and a ds_list named CURRENT_WEAPON.
The code snippet below is written in a script (scr_equip_weapon).
The top code snippet works. but it isn't ideal.
I have over 20 weapons, and I don't want to have to write 20 if statements for each weapon if i can help it.
The bottom code snippet does not work. but it's what I want to do.
i would only need that one line, because the string values for global.equippedWeapon are all the same as the names of my ds_lists.
ex:
- global.equippedWeapon = "SHOTGUN";
- SHOTGUN = ds_list_create();
- global.equippedWeapon = "KNIFE";
- KNIFE = ds_list_create();
So in essence i am trying to reference my ds_lists using a string variable instead of the ds_lists actual ID.
when the 2nd snippet runs, GMS2 throws me this error: "data structure index does not exist"
is there a way to accomplish what I want?
and in that object's create event, I've created a ds_list named SHOTGUN, and a ds_list named CURRENT_WEAPON.
The code snippet below is written in a script (scr_equip_weapon).
The top code snippet works. but it isn't ideal.
I have over 20 weapons, and I don't want to have to write 20 if statements for each weapon if i can help it.
The bottom code snippet does not work. but it's what I want to do.
i would only need that one line, because the string values for global.equippedWeapon are all the same as the names of my ds_lists.
ex:
- global.equippedWeapon = "SHOTGUN";
- SHOTGUN = ds_list_create();
- global.equippedWeapon = "KNIFE";
- KNIFE = ds_list_create();
So in essence i am trying to reference my ds_lists using a string variable instead of the ds_lists actual ID.
when the 2nd snippet runs, GMS2 throws me this error: "data structure index does not exist"
is there a way to accomplish what I want?