• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Strange ds_grid errors

W

wreckitRaccoon

Guest
Grid 17, index out of bounds writing [1,1] - size is [1,121]
Grid 17, index out of bounds writing [1,118] - size is [1,121]
Grid 18, index out of bounds writing [1,114] - size is [1,121]
Grid 19, index out of bounds writing [1,107] - size is [1,121]
Grid 20, index out of bounds writing [1,104] - size is [1,121]

In my mind, this means my logic is correct, I'm writing to cells that exist but there's some kind of initialization or functionality that I'm not doing right. Can you give me some general areas to look at to figure this out?
 

chamaeleon

Member
Grid 17, index out of bounds writing [1,1] - size is [1,121]
Grid 17, index out of bounds writing [1,118] - size is [1,121]
Grid 18, index out of bounds writing [1,114] - size is [1,121]
Grid 19, index out of bounds writing [1,107] - size is [1,121]
Grid 20, index out of bounds writing [1,104] - size is [1,121]

In my mind, this means my logic is correct, I'm writing to cells that exist but there's some kind of initialization or functionality that I'm not doing right. Can you give me some general areas to look at to figure this out?
The message could be seen as a tiny bit confusing. The issue is that first coordinate in your grid is only 1, and you are using 1 as the width index value. If the width is 1 you can only use 0 as the first coordinate.

The values used for the errors in question should probably be

0,0
0,117
0,113
0,106
0,103

Keep the indexing values in the range 0 to width-1 and 0 to height-1.
 
W

wreckitRaccoon

Guest
You can't write to index 1 in a dimension that only has one entry - the index is 0. And why are you using a grid if you've only got one row/column?
It represents a bunch of attributes for a beehive, as you add more beehives, each new hive appends itself onto the x axis of the ds_grid.
 
W

wreckitRaccoon

Guest
The message could be seen as a tiny bit confusing. The issue is that first coordinate in your grid is only 1, and you are using 1 as the width index value. If the width is 1 you can only use 0 as the first coordinate.

The values used for the errors in question should probably be

0,0
0,117
0,113
0,106
0,103

Keep the indexing values in the range 0 to width-1 and 0 to height-1.
That's what I did but I just realized that my code had an if statement that checked if the ds_grid already exists, to add a new row on the creation of a new beehive. So the first time that I create a beehive, it adds a second column and then the i-1 loop writes to the first space because I find the width with get_width which then comes in as 2.
 
W

wreckitRaccoon

Guest
Thanks everyone, I figured it out! I had no idea that the system returns an error when there's no data in column 0 and you try to write in column 1.
 

Nidoking

Member
the system returns an error when there's no data in column 0 and you try to write in column 1
This is incorrect. The system returns an error when there's no column 1 and you try to write in column 1. You can have as little data in column 0 as you like, but the column you're trying to write into needs to exist.
 
Top