J
Jacknoshima
Guest
Hi,
So I'm trying to set up a system where an option in the inventory screen updates the object stored in the inventory ds_grid, and it's acting really weird on me.
So, if I run this code:
My bow in the ds_grid will update just fine (assuming it's in position 0). That it might not be in position 0 means I have to cycle through the grid to find it, and then update it where it is, so I tried:
And this just doesn't work.
I added debugging messages and despite the fact that I KNOW for a fact that my bow is in the inventory, the grid_index doesn't get assigned anything except -1.
However, when I add in the loop but change the ds_grid_set back to being 0 instead of grid index, the debug message shows the correct grid_index and the bow updates.
This is the code:
The above works and the debug message outputs 0, which is the y value of the bow in the ds_grid.
So why does the grid_index not get assigned when I use the grid_index to update the value in the grid after the grid_index should have been assigned but it does get assigned when I use a static number to update the grid?
So I'm trying to set up a system where an option in the inventory screen updates the object stored in the inventory ds_grid, and it's acting really weird on me.
So, if I run this code:
/// @arg object
var object = argument0;
ds_grid_set(global.ds_inventory, 0, 0, object);
var object = argument0;
ds_grid_set(global.ds_inventory, 0, 0, object);
My bow in the ds_grid will update just fine (assuming it's in position 0). That it might not be in position 0 means I have to cycle through the grid to find it, and then update it where it is, so I tried:
/// @arg object
var object = argument0;
var grid_index = -1;
for (var j = 0; j < ds_grid_height(global.ds_inventory); j++)
{
show_debug_message(string(grid_index));
ds_grid_set(global.ds_inventory, 0, grid_index, object);
var object = argument0;
var grid_index = -1;
for (var j = 0; j < ds_grid_height(global.ds_inventory); j++)
{
if ds_grid_get(global.ds_inventory, 0, j) == o_bow_standard
{
}{
grid_index = j;
}show_debug_message(string(grid_index));
ds_grid_set(global.ds_inventory, 0, grid_index, object);
And this just doesn't work.
I added debugging messages and despite the fact that I KNOW for a fact that my bow is in the inventory, the grid_index doesn't get assigned anything except -1.
However, when I add in the loop but change the ds_grid_set back to being 0 instead of grid index, the debug message shows the correct grid_index and the bow updates.
This is the code:
/// @arg object
var object = argument0;
var grid_index = -1;
for (var j = 0; j < ds_grid_height(global.ds_inventory) + 1; j++)
{
show_debug_message(string(grid_index));
ds_grid_set(global.ds_inventory, 0, 0, object);
var object = argument0;
var grid_index = -1;
for (var j = 0; j < ds_grid_height(global.ds_inventory) + 1; j++)
{
if ds_grid_get(global.ds_inventory, 0, j) == o_bow_standard
{
}{
grid_index = j;
}show_debug_message(string(grid_index));
ds_grid_set(global.ds_inventory, 0, 0, object);
The above works and the debug message outputs 0, which is the y value of the bow in the ds_grid.
So why does the grid_index not get assigned when I use the grid_index to update the value in the grid after the grid_index should have been assigned but it does get assigned when I use a static number to update the grid?