G
Geoff Moore
Guest
I'm creating an array of variables to track progress for each area in my game like so:
The first array position for each area could indicate whether the lights are on to start with, for example. Then when I want to change a value, I'm doing:
Since I'm using the same naming convention for my arrays and rooms, can I shorten the second code block to a single line that will modify the first value of whichever array shares the room name with "_state" added at the end?
(Non-working) pseudocode would be:
room_get_name(room)+"_state"+[0]=1;
Any advice on how to do this would be appreciated, or let me know if there's a better approach in general. Thanks for reading!
Code:
area_001_state=[0,0,0]
area_002_state=[0,1,0]
area_003_state=[1,0,1]
...
Code:
if room=area_001 {area_001_state[0]=1;}
else if room=area_002 {area_002_state[0]=1;}
else if room=area_003 {area_003_state[0]=1;}
...
(Non-working) pseudocode would be:
room_get_name(room)+"_state"+[0]=1;
Any advice on how to do this would be appreciated, or let me know if there's a better approach in general. Thanks for reading!