So I was fooling around with scriptGroups and I decided it would be a good alternative to the funky garbage I was doing before to check if a brick was being planted inside certain bounds.
So I've got this:
function inBounds(%brick) {
%client = %brick.client;
if(isObject(%client.lastBound))
if(isInBox(%brick,%client.lastBound))
return %client.lastBound;
for(%i = 0;%i < $LotGroup.getCount;%i++) {
if(isInBox(%brick,$LotGroup.getObject(%i))) {
%client.lastBound= $LotGroup.getObject(%i);
return %client.lastBound;
}
}
return 0;
}
(yes, for the first time in my life I am indenting code)
So that should check if the brick that was planted (via an onPlant package) inside the bounds. Now, on the other hand, I have this.
function fxDTSBrick::onPlant(%brick) {
Parent::onPlant(%brick);
if(!%brick.getDatablock().isBounds && inBounds(%brick) == 0) {
%brick.schedule(0,"delete");
return;
}
if(%brick.getDatablock().isBounds){
$LotGroup.add(%brick);
return;
}
}
When I plant a brick inside of the bounds, the brick gets deleted for being out of bounds (confirmed with console echoes) and the problem is that, in inBounds();, $LotGroup.getCount(); in the For loop returns 0.
If I manually type echo($LotGroup.getCount());, it will echo 0 even when bounds are planted. The only way to add the brick is manually putting into the console $LotGroup.add(brickID); and the syntax is the same in my code and in the console's input. I could use some help with this please.