add box features

This commit is contained in:
Redo
2025-02-26 17:36:12 -07:00
parent cd5b46cc3b
commit dd049be341
21 changed files with 1510 additions and 339 deletions

View File

@ -1,6 +1,12 @@
// This file should not exist. Fix later...
//bls 3
// -------------------------------------------------------------------
// Utility
function ndmessageClient(%client, %ignore, %msg) {
commandToClient(%client, 'centerPrint', "<font:Verdana:20>" @ %msg, 4);
}
//Math functions
///////////////////////////////////////////////////////////////////////////
@ -33,6 +39,21 @@ function ndTransformDirection(%dir, %steps, %mirrX, %mirrY, %mirrZ)
return %dir;
}
function ndColorFToI(%f){
%i = %f*255;
%i = mFloor(%i + 0.5);
return %i;
}
function ndGetColorI(%color){
%color2 =
ndColorFToI(getWord(%color, 0)) SPC
ndColorFToI(getWord(%color, 1)) SPC
ndColorFToI(getWord(%color, 2)) SPC
ndColorFToI(getWord(%color, 3))
;
}
//Get the closest paint color to an rgb value
function ndGetClosestColorID(%rgb)
{
@ -42,7 +63,7 @@ function ndGetClosestColorID(%rgb)
for(%i = 0; %i < 64; %i++)
{
%color = getColorI(getColorIdTable(%i));
%color = ndGetColorI(getColorIdTable(%i));
%diff = vectorLen(vectorSub(%rgb, %color));
@ -71,7 +92,7 @@ function ndGetClosestColorID2(%rgba)
for(%i = 0; %i < 64; %i++)
{
%color = getColorI(getColorIdTable(%i));
%color = ndGetColorI(getColorIdTable(%i));
%alpha = getWord(%color, 3);
%diff = vectorLen(vectorSub(%rgb, %color));
@ -292,7 +313,7 @@ function FxDtsBrick::ndMirrorGhost(%brick, %client, %axis)
}
else
{
messageClient(%client, '', "\c6Sorry, your ghost brick is asymmetric and cannot be mirrored.");
ndmessageClient(%client, '', "\c6Sorry, your ghost brick is asymmetric and cannot be mirrored.");
return;
}
@ -341,7 +362,7 @@ function FxDtsBrick::ndMirrorGhost(%brick, %client, %axis)
}
else
{
messageClient(%client, '', "\c6Sorry, your ghost brick is asymmetric and cannot be mirrored.");
ndmessageClient(%client, '', "\c6Sorry, your ghost brick is asymmetric and cannot be mirrored.");
return;
}
@ -384,7 +405,7 @@ function FxDtsBrick::ndMirrorGhost(%brick, %client, %axis)
}
else
{
messageClient(%client, '', "\c6Sorry, your ghost brick is not vertically symmetric and cannot be mirrored.");
ndmessageClient(%client, '', "\c6Sorry, your ghost brick is not vertically symmetric and cannot be mirrored.");
return;
}
}
@ -443,6 +464,7 @@ function ndCreateSimpleBrickTable()
}
%db.ndSubset = ndSubsetOfDatablock(%db);
if(%db.ndSubset $= "") continue;
%file.openForRead(%db.brickFile);
%file.readLine();
@ -694,34 +716,41 @@ function GameConnection::doFillBricks(%this, %subset)
%box = %this.ndSelectionBox.getWorldBox();
$ND::FillBrickCount = 0;
ndUpdateSpawnedClientList();
ndFillAreaWithBricks(getWords(%box, 0, 2), getWords(%box, 3, 5));
if(%subset == $ND::SubsetLogicBus) {
$ND::FillBrickSubset = $ND::SubsetLogicWire;
ndFillBus(getWords(%box, 0, 2), getWords(%box, 3, 5), getAngleIDFromPlayer(%this.getControlObject()), %this.currentColor);
} else {
ndFillAreaWithBricks(getWords(%box, 0, 2), getWords(%box, 3, 5));
}
//%s = ($ND::FillBrickCount == 1 ? "" : "s");
//messageClient(%this, '', "\c6Filled in \c3" @ $ND::FillBrickCount @ "\c6 brick" @ %s);
%s = ($ND::FillBrickCount == 1 ? "" : "s");
ndmessageClient(%this, '', "\c6Filled in \c3" @ $ND::FillBrickCount @ "\c6 brick" @ %s);
}
$ND::SubsetDefault = 0;
$ND::SubsetLogicWire = 1;
$ND::SubsetLogicBuffer = 2;
$ND::SubsetLogicBufferAl = 3;
$ND::SubsetLogicDff = 4;
$ND::SubsetLogicDffAl = 5;
$ND::SubsetLogicEnabler = 6;
$ND::SubsetLogicEnablerAl = 7;
$ND::SubsetLogicBus = 2;
//$ND::SubsetLogicBuffer = 2;
//$ND::SubsetLogicBufferAl = 3;
//$ND::SubsetLogicDff = 4;
//$ND::SubsetLogicDffAl = 5;
//$ND::SubsetLogicEnabler = 6;
//$ND::SubsetLogicEnablerAl = 7;
// Which subset of fill bricks to use - normal or wire
function ndSubsetOfDatablock(%data){
if(%data.isLogic) {
if(%data.isLogicWire) {
return $ND::SubsetLogicWire;
} else if(strStr(%data.uiName, "Buffer") == 0) {
return (strStr(%data.uiName, "Active Low")==-1) ? $ND::SubsetLogicBuffer : $ND::SubsetLogicBufferAl;
} else if(strStr(%data.uiName, "D FlipFlop") == 0) {
return (strStr(%data.uiName, "Active Low")==-1) ? $ND::SubsetLogicDff : $ND::SubsetLogicDffAl;
}else if(strStr(%data.uiName, "Enabler") == 0) {
return (strStr(%data.uiName, "Active Low")==-1) ? $ND::SubsetLogicEnabler : $ND::SubsetLogicEnablerAl;
//} else if(strStr(%data.uiName, "Buffer") == 0) {
// return (strStr(%data.uiName, "Active Low")==-1) ? $ND::SubsetLogicBuffer : $ND::SubsetLogicBufferAl;
//} else if(strStr(%data.uiName, "D FlipFlop") == 0) {
// return (strStr(%data.uiName, "Active Low")==-1) ? $ND::SubsetLogicDff : $ND::SubsetLogicDffAl;
//}else if(strStr(%data.uiName, "Enabler") == 0) {
// return (strStr(%data.uiName, "Active Low")==-1) ? $ND::SubsetLogicEnabler : $ND::SubsetLogicEnablerAl;
} else {
return $ND::SubsetDefault;
return "";
}
} else {
return $ND::SubsetDefault;