Badspot's
Script_TerrainBuildRules uses this to determine if a 64x baseplate is lined up with another 64x baseplate. It may help.
// Also, it better be lined up with an existing baseplate
// Search for nearby plates and check their relative position
%pos = %plantedBrick.getPosition();
%box = "32.1 32.1 0.1";
%mask = $TypeMasks::FxBrickAlwaysObjectType;
%plantX = getWord(%plantedBrick.getPosition(), 0);
%plantY = getWord(%plantedBrick.getPosition(), 1);
initContainerBoxSearch(%pos, %box, %mask);
while (%searchObj = containerSearchNext())
{
if(%searchObj.getDataBlock().getID() != brick64x64fData.getID())
continue;
if(%searchObj.getDistanceFromGround() != 0)
continue;
if(!%searchObj.isPlanted())
continue;
if(%searchObj.isDead())
continue;
if(%searchObj == %plantedBrick)
continue;
//To be lined up, the x or y position must be the same
%searchX = getWord(%searchObj.getPosition(), 0);
%searchY = getWord(%searchObj.getPosition(), 1);
// Note: We compare with subtraction like this because direct
// comparison with "==" on floating point numbers is not reliable
if(mAbs(%searchX - %plantX) < 0.05 || mAbs(%searchY - %plantY) < 0.05 )
return;
}
//If we got this far it must not have been lined up with any existing plates
CommandToClient(%client, 'MessageBoxOK', "Invalid Placement", "You must line up your baseplate with the existing grid.");
%plantedBrick.killBrick();