T
Toxicosis
Guest
I'm having some problems.
Basically, on my destroy event for an instance, I had it discard all tiles that were associated with it. Whether it had tiles associated with it or not depended on a variable, tiling, which was called during the destroy event.
However, that variable was initialized during the create event. I made now a script during the same create event, which destroys other instances of the same object if they are adjacent and can be replaced by an enlarged version of the calling instance. So, basically, it replaces other bricks if they are too close by stretching itself over their space.
However, during the destroy event, the tiling variable is not set, which causes a crash on running. I don't understand what's going on. Supposedly, as soon as those bricks were placed in the room, they'd have their create event run, and the variable in question is initialized during the create event.
Even placing tiling = 1 in the start of the create event returns a tiling not set error. This is odd. I can already think of a workaround, but in the meantime, I'd like to know your thoughts. I literally set that variable first thing in the create event, and there is nothing that ought to remove it.
Basically, on my destroy event for an instance, I had it discard all tiles that were associated with it. Whether it had tiles associated with it or not depended on a variable, tiling, which was called during the destroy event.
However, that variable was initialized during the create event. I made now a script during the same create event, which destroys other instances of the same object if they are adjacent and can be replaced by an enlarged version of the calling instance. So, basically, it replaces other bricks if they are too close by stretching itself over their space.
However, during the destroy event, the tiling variable is not set, which causes a crash on running. I don't understand what's going on. Supposedly, as soon as those bricks were placed in the room, they'd have their create event run, and the variable in question is initialized during the create event.
Even placing tiling = 1 in the start of the create event returns a tiling not set error. This is odd. I can already think of a workaround, but in the meantime, I'd like to know your thoughts. I literally set that variable first thing in the create event, and there is nothing that ought to remove it.
Code:
//CREATE EVENT:
tiling = true;
obj_break_hard_create();
scr_brick_economize();
//DESTROY EVENT:
tile_discard();
//TILE_DISCARD:
if tiling = false exit;
var crn_tile;
var max_tile;
max_tile = array_length_1d(tileedge);
for (crn_tile = 0; crn_tile < max_tile; crn_tile++)
{
if tile_exists(tileedge[crn_tile])
{
tile_delete(tileedge[crn_tile]);
}
}
//ERROR MESSAGE:
Variable obj_brick_economic.tiling(100209, -2147483648) not set before reading it.
at gml_Script_tile_discard (line 1) - if tiling = false exit;
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_tile_discard (line 1)
called from - gml_Object_obj_brick_economic_DestroyEvent_1 (line 1) - tile_discard();