This is untested, but it should be pretty close.
%xyz2 = %player.getPosition();
%x2 = getWord(%xyz2,0);
%y2 = getWord(%xyz2,1);
%z2 = getWord(%xyz2,2);
%brickMax = getWords(%brick.getWorldBox(),3,5);
%brickMin = getWords(%brick.getWorldBox(),0,2);
%brickMaxX = getWord(%brickMax,0);
%brickMaxY = getWord(%brickMax,1);
%brickMaxZ = getWord(%brickMax,2);
%brickMinX = getWord(%brickMin,0);
%brickMinY = getWord(%brickMin,1);
%brickMinZ = getWord(%brickMin,2);
if(%x2 - %brickMaxX < %x2 - %brickMinX)
{
%x1 = %brickMaxX;
}
else
{
%x1 = %brickMinX;
}
if(%y2 - %brickMaxY < %y2 - %brickMinY)
{
%y1 = %brickMaxY;
}
else
{
%y1 = %brickMinY;
}
if(%z2 - %brickMaxZ < %z2 - %brickMinZ)
{
%z1 = %brickMaxZ;
}
else
{
%z1 = %brickMinZ;
}
%x = (%x1 - %x2) * -1;
%y = (%y1 - %y2) * -1;
%z = (%z1 - %z2) * -1;
%distance = mSqrt(%x * %x + %y * %y + %z * %z);