Daroc Mike
Member
Hi
Let's say I have an array arr_power_up_pool = ["magnet","heart","triple_shot"]
The length of arr_power_up_pool changes over the course of the game, meaning that it is empty at the beginning and could have up to 20 or more entries (no fix maximum).
I want to be able to store the values one after the other inside the "pos_01" - "pos_03" variables (in this case01- 03, but this would of course go up to whatever the amount inside the array is).
I know that I can store specific positions of an array in a new variable using array_get. But how do I get something like
pos_01 = "magnet"
pos_02 = "heart"
pos_03 = "triple_shot"
...
I came up with the following:
The problem is, it stores the whole array in pos_, instead of the individual values. And I have no idea how to tell Game Maker to automatically name "pos_" correctly (pos_ + 01, 02, 03 and so on), depending on which position inside arr_power_up_pool the value is.
Let's say I have an array arr_power_up_pool = ["magnet","heart","triple_shot"]
The length of arr_power_up_pool changes over the course of the game, meaning that it is empty at the beginning and could have up to 20 or more entries (no fix maximum).
I want to be able to store the values one after the other inside the "pos_01" - "pos_03" variables (in this case01- 03, but this would of course go up to whatever the amount inside the array is).
I know that I can store specific positions of an array in a new variable using array_get. But how do I get something like
pos_01 = "magnet"
pos_02 = "heart"
pos_03 = "triple_shot"
...
I came up with the following:
GML:
power_up_pool_length = array_length(arr_power_up_pool);
if(!(array_length(arr_power_up_pool) == 0))
{
for(i = 0; i < power_up_pool_length; i += 1) {
pos_ = array_get(arr_power_up_pool,i);
}
}