B
blabluxd
Guest
Hello ,
I have a question over a code I am breaking my head over for several days now!
I have this line of code where you get different rewards depending on the number. For example if you win coins, you get +100 coins etc.
In this case you win a new football. I have a ds_map that stores 20 footballs under the ID "Football1", "Football2" and so on. They all store the value 0 for locked and 1 for owned. When you run the game for the first time the ds map gets created and the player owns only "Football 1".
Now when winning a football, the game should choose a random ball and check if its locked and then make it owned. So change the value from 0 to 1. If the ball has the value 1 already, so it is owned already, then it should check for another ball. Thats the part where I'm stuck. I dont know how to search as long until a locked ball is found!
I would really appreciate any help
greetings
I have a question over a code I am breaking my head over for several days now!
I have this line of code where you get different rewards depending on the number. For example if you win coins, you get +100 coins etc.
In this case you win a new football. I have a ds_map that stores 20 footballs under the ID "Football1", "Football2" and so on. They all store the value 0 for locked and 1 for owned. When you run the game for the first time the ds map gets created and the player owns only "Football 1".
Code:
ini_open("saveData.ini");
if (ini_read_real("Game", "OpenedForFirstTime", 1) == 1) {
ini_write_real("Game", "OpenedForFirstTime", 0);
// create the ds map for footballs
global.footballs = ds_map_create();
// add all footballs as locked
for (var i = 1; i < number_of_footballs; i++) // Check star count and save in 1D array
{
ds_map_add(global.footballs, "Football"+string(i), 0);
}
// change football 1 as unlocked
ds_map_replace(global.footballs, "Football1", 1);
}
Code:
// get reward for football
if (reward == 192) {
var random = irandom_range(2,20);
if (ds_map_find_value(global.footballs, "Football"+string(random)) == 0) {
ds_map_replace(global.footballs, "Football"+string(random), 1)
}
greetings