deathzero021
Member
The error:
Now this implies that I am trying to write to a grid in a position that doesn't exist. I used the debugger and set many break points, going one step at a time until I found the culprit.
(for context, chunk[#] holds ds_map id's)
Now as you can see, there is no writing taking place here. So the error message doesn't make sense. However, something is going wrong as the script is failing to do it's job. Previously, the script was working just fine until I decided I had to change a 2d array to a grid. ("chunk[#]" was originally "chunk[]")
So the problem started after I made that change. Oddly enough, this grid is accessed this way in all of the scripts in the game, and it's only a problem here. I've spent a lot of time debugging this and it took way too long to track it down and now that I finally have, I'm completely stumped as I can't make sense of the error.
Thinking deeply on it, if it were trying to access a position that didn't exist, a 0 would be returned, so this whole script would continue to execute (which is why it doesn't crash I suppose) it would just be doing a lot of things incorrectly resulting in the chaos that is going on in the game.
Is there something I am misunderstanding about how to use accessors? Or is the error message just incorrectly saying "writing" when it should be saying "reading"? Any tips or ideas would be greatly appreciated.
Code:
Grid 0, index out of bounds writing [-1,0] - size is [4,4]
Code:
// Left side
if (bx-1 > -1)
{
if (ds_grid_get(ds_map_find_value(chunk[#argument0,argument1],argument2),bx-1,by) == AIR) v_sideleft = true;
}
else
{
if (chunk[#argument0-1,argument1] > 0) // this line causes the message
{
if (ds_grid_get(ds_map_find_value(chunk[#argument0-1,argument1],argument2),15,by) == AIR) v_sideleft = true;
}
}
Now as you can see, there is no writing taking place here. So the error message doesn't make sense. However, something is going wrong as the script is failing to do it's job. Previously, the script was working just fine until I decided I had to change a 2d array to a grid. ("chunk[#]" was originally "chunk[]")
So the problem started after I made that change. Oddly enough, this grid is accessed this way in all of the scripts in the game, and it's only a problem here. I've spent a lot of time debugging this and it took way too long to track it down and now that I finally have, I'm completely stumped as I can't make sense of the error.
Thinking deeply on it, if it were trying to access a position that didn't exist, a 0 would be returned, so this whole script would continue to execute (which is why it doesn't crash I suppose) it would just be doing a lot of things incorrectly resulting in the chaos that is going on in the game.
Is there something I am misunderstanding about how to use accessors? Or is the error message just incorrectly saying "writing" when it should be saying "reading"? Any tips or ideas would be greatly appreciated.