[solved] using initcontainerboxsearch for lots in CityRPG

Author Topic: [solved] using initcontainerboxsearch for lots in CityRPG  (Read 2245 times)

This is supposed to change the ownership of the lot and all bricks on it, but atm it's doing nothing with the bricks on the lot; can someone tell me what I did wrong here?
solution:
Code: [Select]
function fxDTSBrick::transferLot(%brick, %targetBG)
{
%ownerBG = getBrickGroupFromObject(%brick);

if(isObject(%ownerBG))
%ownerBG.remove(%brick);
if(isObject(%targetBG))
%targetBG.add(%brick);

%boxSize = (getWord(%brick.trigger.scale, 0) / 2.5) * 10 SPC (getWord(%brick.trigger.scale, 1) / 2.5) * 10 SPC (getWord(%brick.trigger.scale, 2) / 2.5) * 10;
initContainerBoxSearch(%brick.trigger.getWorldBoxCenter(), %boxSize, $typeMasks::fxBrickObjectType);

while(isObject(%nBrick = containerSearchNext()))
{
if(!isObject(%nBrick) || !%nBrick.isPlanted)
continue;

%ownerBG = getBrickGroupFromObject(%nBrick);

if(isObject(%ownerBG))
%ownerBG.remove(%nBrick);

if(isObject(%targetBG))
%targetBG.add(%nBrick);
}
}
« Last Edit: August 17, 2014, 03:00:04 PM by Aoki² »

Personally, I would use brick stacks, just like the duplorcator did. Try looking at that.

You also have to change %brick.client and %brick.stackBL_ID.

hm for some reason the box size was .1 of what it was supposed to be so i fixed it by multiplying everything here by 10
Code: [Select]
%boxSize = (getWord(%brick.trigger.scale, 0) / 2.5) * 10 SPC (getWord(%brick.trigger.scale, 1) / 2.5) * 10 SPC (getWord(%brick.trigger.scale, 2) / 2.5) * 10;
i copied the code right from another place in the mod, i wonder if this was intentional or a bug
« Last Edit: August 17, 2014, 06:19:12 AM by Aoki² »

hm for some reason the box size was .1 of what it was supposed to be so i fixed it by multiplying everything here by 10
Code: [Select]
%boxSize = (getWord(%brick.trigger.scale, 0) / 2.5) * 10 SPC (getWord(%brick.trigger.scale, 1) / 2.5) * 10 SPC (getWord(%brick.trigger.scale, 2) / 2.5) * 10;
i copied the code right from another place in the mod, i wonder if this was intentional or a bug
You could just not use a box search or raycast at all and still get all the bricks on top of it. Just use a for/while statement and %brick.getNumUpBricks(); + %brick.getUpBrick(%num);

You could just not use a box search or raycast at all and still get all the bricks on top of it. Just use a for/while statement and %brick.getNumUpBricks(); + %brick.getUpBrick(%num);
hanging bricks are left out

hanging bricks are left out
Then use getNumDownBricks() and getDownBrick(num) too

Then use getNumDownBricks() and getDownBrick(num) too
I would rather use initContainerBoxSearch because even with getDownBrick there could be some trouble with zones/floating bricks, besides I got it working already.
« Last Edit: August 17, 2014, 08:20:02 AM by Aoki² »