function isCoveredCompletely(%bBrick,%tBrick)
{
%bBox = %bBrick.getWorldBox();
%bMinX = getWord(%bBox,0);
%bMinY = getWord(%bBox,1);
%bMaxX = getWord(%bBox,3);
%bMaxY = getWord(%bBox,4);
%bMaxZ = getWord(%bBox,5);
%tBox = %tBrick.getWorldBox();
%tMinX = getWord(%tBox,0);
%tMinY = getWord(%tBox,1);
%tMinZ = getWord(%tBox,2);
%tMaxX = getWord(%tBox,3);
%tMaxY = getWord(%tBox,4);
if(%bBrick.getNumUpBricks() != 1 || %bMaxZ != %tMinZ)
return 0;
%bDiag = mSqrt(mPow(%bMaxX - %bMinX,2) + mPow(%bMaxY - %bMinY,2));
%tDiag = mSqrt(mPow(%tMaxX - %tMinX,2) + mPow(%tMaxY - %tMinY,2));
if(%tDiag < %bDiag || %tMaxX < %bMaxX || %tMaxY < %bMaxY || %tMinX > %bMinX || %tMinY > %bMinY)
return 0;
return 1;
}
I used a lot of variables so you can see what I did. I also used two if statements instead of one because I do not like monolithic if statements. This should work, but it is untested. Knowing myself, I would guess that I have made one or two silly mistakes in the code, so look for them if it doesn't work.
Edit: Added parentheses after getNumUpBricks
Edit2: Added more triggers to if statement