R
Reaxgrim
Guest
Trying to get this code to loop through my inventory grid and check if the grid slot is "noone" and if it is "noone" add in an item and then stop.
but it seems to add the item to every other grid slot. ie: 1,0 - 2,0 - 3,0 etc
instead of just adding it to the first "noone" it comes across and then stops.
Below is the code
and debug code-
-4 is NOONE (ie: empty)
-1 is where its added the item.
but it should only add the code to 00 then 01 then 02 or whatever ones it comes to thats -4 (empty)
any help would be great
cheers
Reax.
but it seems to add the item to every other grid slot. ie: 1,0 - 2,0 - 3,0 etc
instead of just adding it to the first "noone" it comes across and then stops.
Below is the code
Code:
/// @description Player Inventory Add Script
for (var xp = 0; xp < ds_grid_width(argument0); xp++)
{
for (var yp = 0; yp < ds_grid_height(argument0); yp++ )
{
if (argument0[# xp,yp] != noone){
show_debug_message(string(xp) + string(yp) + string(" NOT EMPTY"));
} else {
show_debug_message(string(xp) + string(yp) + string(" EMPTY"));
ds_grid_add(argument0,xp,yp,argument1);
show_debug_message("Added Item");;
break;
}
}
}
-4 is NOONE (ie: empty)
-1 is where its added the item.
Code:
00-1
01-4
02-4
03-4
10-1
11-4
12-4
13-4
20-1
21-4
22-4
23-4
30-1
31-4
32-4
33-4
but it should only add the code to 00 then 01 then 02 or whatever ones it comes to thats -4 (empty)
any help would be great
cheers
Reax.