I wrote some code for checking if a given location is valid for building things, using local variable "_output" as accumulator; however, my attempt to update the accumulator in a with() loop appeared to have no effect.
In short, _output is not changed in the with() loop, even when I rewrite the problematic line with
Local variables had always been modifiable in contexts like this before, and the "testing line" below the problem line has shown that the with() loop was iterating through multiple instances. Why then, is the local variable not being updated?
(I know there are work-arounds, but I also want to know why things are like this)
GML:
///@arg build_x
///@arg build_y
var _output = true;
_output = _output and point_distance(argument0,argument1,oPlanet.x,oPlanet.y)-3<sprite_get_width(sCircle_D35)/2+oPlanet.sprite_width/2;
with(oNode){
_output = _output and point_distance(argument0,argument1,x,y)-3<sprite_get_width(sCircle_D35); //<-Problem here!!!
cs_newsFlash(mouse_x,mouse_y,c_white,"test"); //<-testing line
}
return(_output);
_output = false;
Local variables had always been modifiable in contexts like this before, and the "testing line" below the problem line has shown that the with() loop was iterating through multiple instances. Why then, is the local variable not being updated?
(I know there are work-arounds, but I also want to know why things are like this)