S
skaiiwalker
Guest
I'm trying to build a board based game where you move pieces around on a board. I want the piece to be locked to a grid based on the board. In the current version of the game, it crashed as soon as it loads up. Here's the error:
___________________________________________
############################################################################################
ERROR in
action number 1
of Alarm Event for alarm 1
for object obj_gamePiece:
Variable obj_gameBoard.col(100133, -2147483648) not set before reading it.
at gml_Object_obj_gamePiece_Alarm_1 (line 3) - self.x = obj_gameBoard.x + 25 + (50 * self.col);
############################################################################################
gml_Object_obj_gamePiece_Alarm_1 (line 3)
___________________________________________
Here's the code in the gamepiece object that is breaking for some reason:
So the code really doesn't like my trying to call its own variables instead of gameboard variables in the with section. I don't know why that is. Please help me understand how to fix this
___________________________________________
############################################################################################
ERROR in
action number 1
of Alarm Event for alarm 1
for object obj_gamePiece:
Variable obj_gameBoard.col(100133, -2147483648) not set before reading it.
at gml_Object_obj_gamePiece_Alarm_1 (line 3) - self.x = obj_gameBoard.x + 25 + (50 * self.col);
############################################################################################
gml_Object_obj_gamePiece_Alarm_1 (line 3)
___________________________________________
Here's the code in the gamepiece object that is breaking for some reason:
GML:
// create event
row = 5;
col = 0;
// step event
if (!global.isPaused)
{
if (keyboard_check_released(ord("A")))
{
col--;
}
if (keyboard_check_released(ord("D")))
{
col++;
}
if (keyboard_check_released(ord("W")))
{
row--;
}
if (keyboard_check_released(ord("S")))
{
row++;
}
}
alarm[1] = 1;
// alarm 1 event
// this code kept getting angry at me for trying to read from the gameboard
// object before it was created, so I moved it into alarm 1
with (obj_gameBoard)
{
self.x = obj_gameBoard.x + 25 + (50 * self.col);
self.y = obj_gameBoard.y + 25 + (50 * self.row);
}