Use a box search that's like 0.1 units larger than the brick, there is no default function for this
This is more-or-less what I would do. Try this:
function getUpBrick(%brick) {
%db = %brick.getDatablock();
%box = 0.5 * %db.brickSizeX - 0.05
SPC 0.5 * %db.brickSizeY - 0.05
SPC 0.1;
%boxPos = vectorAdd(%brick.position, "0 0" SPC (0.1 * %db.brickSizeZ + 0.1));
initContainerBoxSearch(%boxPos, %box, $TypeMasks::fxBrickObjectType);
while (isObject(%b = containerSearchNext()))
%bricksFound = %b SPC %bricksFound;
%bricksFound = rTrim(%bricksFound);
return %bricksFound;
}
where
%brick is the brick you want to search above. The container box is shaped and positioned so that the function only finds bricks which are a single stud above the given
%brick, and so that the
%brick itself isn't included in the container. I tested this function, and it worked for me.