(Solved)help me understand what im doing wrong

EvanSki

Raccoon Jam Host
Code:
cmd_list_size = 9; //max size of grid
cmd_list = ds_grid_create(1,cmd_list_size); //create grid
ds_grid_clear(cmd_list,0);

var grid = cmd_list;

//set all commands to false
for (var i = 0; i < cmd_list_size; i++)
{
    ds_grid_add(grid, 1, i, false);
}

//COMMANDS                         
grid[# 0, 0] = "LOGOFF";
grid[# 0, 1] = "HELLO"; 
grid[# 0, 2] = "2"; 
grid[# 0, 3] = "3"; 
grid[# 0, 4] = "4"; 
grid[# 0, 5] = "5"; 
grid[# 0, 6] = "6"; 
grid[# 0, 7] = "7"; 
grid[# 0, 8] = "8"; 
grid[# 0, 9] = "9";
Debug_SendGameStructure: packet size 72259
Grid 0, index out of bounds writing [1,0] - size is [1,9]
Grid 0, index out of bounds writing [1,1] - size is [1,9]
Grid 0, index out of bounds writing [1,2] - size is [1,9]
Grid 0, index out of bounds writing [1,3] - size is [1,9]
Grid 0, index out of bounds writing [1,4] - size is [1,9]
Grid 0, index out of bounds writing [1,5] - size is [1,9]
Grid 0, index out of bounds writing [1,6] - size is [1,9]
Grid 0, index out of bounds writing [1,7] - size is [1,9]
Grid 0, index out of bounds writing [1,8] - size is [1,9]
Grid 0, index out of bounds writing [0,9] - size is [1,9]


But heres the thing, the ds_grid works fine and is filled with all the information I want in the correct places
I dont understand at all, what the problem is
 
Last edited:

Binsk

Member
You are creating a grid size of 1x9 and trying to store values in a grid of size 2x9 as far as I can tell.

Change the grid size to 2x9 at creation.
 

immortalx

Member
Code:
ds_grid_add(grid, 1, i, false);
You first dimension has a size of 1, so the only index there is zero. Change your code to
Code:
ds_grid_add(grid, 0, i, false);
 

EvanSki

Raccoon Jam Host
changing this to 2
Code:
cmd_list = ds_grid_create(2,cmd_list_size); //create grid
gives me this
Grid 0, index out of bounds writing [0,9] - size is [2,9]
 

chamaeleon

Member
changing this to 2
Code:
cmd_list = ds_grid_create(2,cmd_list_size); //create grid
gives me this
Grid 0, index out of bounds writing [0,9] - size is [2,9]
If your second grid dimension is 9, you can only use 0 through 8 indices.
 
Last edited by a moderator:

EvanSki

Raccoon Jam Host
Code:
cmd_list_size = 10; //max size of grid
cmd_list = ds_grid_create(2,cmd_list_size); //create grid
ds_grid_clear(cmd_list,0);

var grid = cmd_list;

//set all commands to false
for (var i = 0; i < cmd_list_size; i++)
{
    ds_grid_add(grid, i, 0, true);
}

//COMMANDS                         
grid[# 0, 0] = "LOGOFF";
grid[# 0, 1] = "HELLO";
grid[# 0, 2] = "2";
grid[# 0, 3] = "3";
grid[# 0, 4] = "4";
grid[# 0, 5] = "5";
grid[# 0, 6] = "6";
grid[# 0, 7] = "7";
grid[# 0, 8] = "8";
grid[# 0, 9] = "9";

Debug_SendGameStructure: packet size 72287
Grid 0, index out of bounds writing [2,0] - size is [2,10]
Grid 0, index out of bounds writing [3,0] - size is [2,10]
Grid 0, index out of bounds writing [4,0] - size is [2,10]
Grid 0, index out of bounds writing [5,0] - size is [2,10]
Grid 0, index out of bounds writing [6,0] - size is [2,10]
Grid 0, index out of bounds writing [7,0] - size is [2,10]
Grid 0, index out of bounds writing [8,0] - size is [2,10]
Grid 0, index out of bounds writing [9,0] - size is [2,10]

and there not being set to true
 

immortalx

Member
It seems you are confusing size with what the indices for accessing the grid should be. You set your grid to have a size of 1,9. That means that for the first dimension the minimum (and only) index is zero.
For the second dimension the minimum index is zero and the maximum is 8.

EDIT chamaleon beat me to it!
 

Binsk

Member
Show us your modified code.

You created a grid of size 2x10 now (as stated in your error) but in your loop are incrementing the x-axis instead of the y-axis. Notice how it says out of bounds [9, 0].

Change that.
 

EvanSki

Raccoon Jam Host
what I want is a grid with two columns 0,1
column 0 holds the command name
column 1 holds wither its true or false
 

Binsk

Member
Alright. My post still stands. Your initial code looped through your rows at column 2. Your modified code is looping through columns at row. This is incorrect, change it back.

This is causing the error because you are trying to loop through 10 columns when you defined 2.
 

EvanSki

Raccoon Jam Host
changing
Code:
ds_grid_add(grid, i, 0, true);
to
Code:
ds_grid_add(grid, 0, i, true);
Now My problem is that column 1 is not being filled its just stuck at 0
 
Last edited:

chamaeleon

Member
changing
Code:
ds_grid_add(grid, i, 0, true);
to
Code:
ds_grid_add(grid, 0, i, true);
Now My problem is that column 1 is not being filled its just stuck at 0
I think you're best served by showing complete code snippets as you change things. Anyway, why would column 1 be filled if you are modifying the content in column 0? If you want to modify column 1 use 1 as the index, not 0. And why do you swap column and row indices? Pick one and stick with it while keeping the grid construction consistent with the choice you make throughout your code. And do look up what ds_grid_add() does, so you are not surprised later. It does not just set a value, it changes the existing value by performing addition (or string concatenation if the grid cell contains a string), and does not allow for different types between what is stored before and what is given as an argument to add.
 
Last edited by a moderator:
Top