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,3 +1,5 @@
//bls 4
// This file should not exist. Fix later...
// -------------------------------------------------------------------
@ -200,6 +202,21 @@ function NDM_BoxSelect::onSelectObject(%this, %client, %obj, %pos, %normal)
%client.ndUpdateBottomPrint();
}
function ndRound(%v, %step) {
return mFloor(%v/%step + 0.5)*%step;
}
function ndCorrectBox(%box) {
%xl = ndRound(getWord(%box, 0), 0.5);
%yl = ndRound(getWord(%box, 1), 0.5);
%zl = ndRound(getWord(%box, 2), 0.2);
%xh = ndRound(getWord(%box, 3), 0.5);
%yh = ndRound(getWord(%box, 4), 0.5);
%zh = ndRound(getWord(%box, 5), 0.2);
%box2 = %xl SPC %yl SPC %zl SPC %xh SPC %yh SPC %zh;
return %box2;
}
function ndGetBoxFromRom(%b) {
%db = %b.getDatablock();
%box = %b.getWorldBox();
@ -207,7 +224,7 @@ function ndGetBoxFromRom(%b) {
%bh = getWords(%box, 3, 5);
%bl = vectorAdd(%bl, "0 0 " SPC (%db.brickSizeZ * 0.2));
%bh = vectorAdd(%bh, "0 0 " SPC (%db.logicRomZ * 0.2));
return %bl SPC %bh;
return ndCorrectBox(%bl SPC %bh);
}
function ndGetBoxFromZone(%b) {
@ -216,7 +233,7 @@ function ndGetBoxFromZone(%b) {
%scale = %z.getScale(); %sx = getWord(%scale, 0); %sy = getWord(%scale, 1); %sz = getWord(%scale, 2);
%bl = %pos;
%bh = vectorAdd(%pos, %sx SPC (-%sy) SPC %sz);
return %bl SPC %bh;
return ndCorrectBox(%bl SPC %bh);
}

View File

@ -48,7 +48,7 @@ function NDM_FillColor::onPlantBrick(%this, %client)
//Admin limit
if($Pref::Server::ND::PaintAdminOnly && !%client.isAdmin)
{
messageClient(%client, '', "\c6Paint Mode is admin only. Ask an admin for help.");
ndmessageClient(%client, '', "\c6Paint Mode is admin only. Ask an admin for help.");
return;
}
@ -63,7 +63,7 @@ function NDM_FillColor::onPlantBrick(%this, %client)
//Admin limit
if($Pref::Server::ND::PaintFxAdminOnly && !%client.isAdmin)
{
messageClient(%client, '', "\c6Paint Fx Mode is admin only. Ask an admin for help.");
ndmessageClient(%client, '', "\c6Paint Fx Mode is admin only. Ask an admin for help.");
return;
}

View File

@ -1,3 +1,5 @@
//bls 4
// This file should not exist. Fix later...
// -------------------------------------------------------------------
@ -26,6 +28,7 @@ function NDM_PlantCopy::onChangeMode(%this, %client, %nextMode)
{
%client.ndSelection.deleteData();
}
%client.ndOwnership = false;
}
//Kill this mode
@ -33,6 +36,7 @@ function NDM_PlantCopy::onKillMode(%this, %client)
{
//Destroy the selection
%client.ndSelection.delete();
%client.ndOwnership = false;
}
@ -112,12 +116,21 @@ function NDM_PlantCopy::onPlantBrick(%this, %client)
{
if($Pref::Server::ND::FloatAdminOnly && !%client.isAdmin)
{
messageClient(%client, '', "\c6Force Plant has been disabled because it is admin only. Ask an admin for help.");
ndmessageClient(%client, '', "\c6Force Plant has been disabled because it is admin only. Ask an admin for help.");
%client.ndForcePlant = false;
}
}
%this.conditionalPlant(%client, %client.ndForcePlant);
if(%client.ndOwnership) {
if(!%client.isAdmin) {
%client.ndOwnership = false;
ndmessageClient(%client, '', "\c6Ownership plant has been disabled because it is admin only.");
}
}
%this.conditionalPlant(%client, %client.ndForcePlant, %client.ndOwnership);
%client.ndOwnership = false;
}
//Cancel Brick
@ -160,7 +173,9 @@ function NDM_PlantCopy::getBottomPrint(%this, %client)
%l0 = "Pivot: \c3" @ (%client.ndPivot ? "Whole Selection" : "Start Brick") @ "\c6 [Prev Seat]";
if(isObject(%client.ndSelection.targetGroup))
if(%client.ndOwnership)
%l1 = "Planting as: Original Owner";
else if(isObject(%client.ndSelection.targetGroup))
%l1 = "Planting as: \c3" @ %client.ndSelection.targetGroup.name;
else
%l1 = "Size: \c3" @ %x @ "\c6 x \c3" @ %y @ "\c6 x \c3" @ %z @ "\c6 Plates";
@ -222,7 +237,7 @@ function NDM_PlantCopy::moveBricksTo(%his, %client, %pos, %normal)
}
//Check time limit and attempt to plant bricks
function NDM_PlantCopy::conditionalPlant(%this, %client, %force)
function NDM_PlantCopy::conditionalPlant(%this, %client, %force, %ownership)
{
//Check timeout
if(!%client.isAdmin && %client.ndLastPlantTime + ($Pref::Server::ND::PlantTimeoutMS / 1000) > $Sim::Time)
@ -252,7 +267,7 @@ function NDM_PlantCopy::conditionalPlant(%this, %client, %force)
getTrustLevel(%client, %client.ndSelection.targetGroup) < 1 &&
(!%client.isAdmin || !$Pref::Server::ND::AdminTrustBypass2))
{
messageClient(%client, '', "\c6You need build trust with \c3"
ndmessageClient(%client, '', "\c6You need build trust with \c3"
@ %client.ndSelection.targetGroup.name @ "\c6 to plant bricks in their group.");
return;
@ -264,5 +279,5 @@ function NDM_PlantCopy::conditionalPlant(%this, %client, %force)
%ang = %client.ndSelection.ghostAngleID;
%client.ndSetMode(NDM_PlantCopyProgress);
%client.ndSelection.startPlant(%pos, %ang, %force);
%client.ndSelection.startPlant(%pos, %ang, %force, %ownership);
}

View File

@ -1,3 +1,5 @@
//bls 4
// This file should not exist. Fix later...
// -------------------------------------------------------------------
@ -71,8 +73,13 @@ function NDM_StackSelect::onSelectObject(%this, %client, %obj, %pos, %normal)
//Start selection
%client.ndSetMode(NDM_StackSelectProgress);
if(%client.ndMultiSelect)
if(%client.ndSelection.brickCount==0)
%client.ndInitialMultiSelect = %client.ndMultiSelect;
if(%client.ndInitialMultiSelect)
%client.ndSelection.startStackSelectionAdditive(%obj, 2, %client.ndLimited);
else if(%client.ndMultiSelect)
%client.ndSelection.startStackSelectionAdditive(%obj, %client.ndDirection, %client.ndLimited);
else
%client.ndSelection.startStackSelection(%obj, %client.ndDirection, %client.ndLimited);

View File

@ -1,3 +1,5 @@
//bls 3
// This file is way too big. Fix later...
// -------------------------------------------------------------------
@ -11,6 +13,7 @@
// $NS[%s, "P", %i] - Position
// $NS[%s, "R", %i] - Rotation
// $NS[%s, "O", %i] - Owner BL_ID
// $NS[%s, "NT", %i] - Brick name
// $NS[%s, "HN", %n] - Name exists in selection
// $NS[%s, "PR", %i] - Print
@ -123,6 +126,50 @@ function ND_Selection::onRemove(%this)
//Stack Selection
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ndBoxSearchAdjacentBricks(%brick, %boxadd, %limited){
%box = %brick.getWorldBox();
%boxsize = vectorSub(getWords(%box, 3, 5), getWords(%box, 0, 2));
%boxsize = vectorAdd(%boxsize, %boxadd);
//%mask = %limited ? $TypeMasks::FxBrickObjectType : $TypeMasks::FxBrickAlwaysObjectType;
%mask = $TypeMasks::FxBrickAlwaysObjectType;
initContainerBoxSearch(%brick.getPosition(), %boxsize, %mask);
}
function ndGetNextAdjacentBrick(%brick, %limited) {
if($ND_boxSearchDir$="" || $ND_boxSearchBrick!=%brick) {
$ND_boxSearchDir = 1;
$ND_boxSearchBrick = %brick;
ndBoxSearchAdjacentBricks(%brick, "0.2 -0.2 -0.2", %limited);
}
for(%i=0; %i<100; %i++) {
//while(true) {
%brick2 = containerSearchNext();
//echo(%i SPC %brick2);
if(%brick2) {
//if(%brick2.colorId==%brick.colorId && %brick2!=%brick) {
if(
(!%limited || %brick2.colorId==%brick.colorId) &&
%brick2!=%brick
) {
//echo("hit");
return %brick2;
}
} else {
if($ND_boxSearchDir==1) {
$ND_boxSearchDir = 2;
ndBoxSearchAdjacentBricks(%brick, "-0.2 0.2 -0.2", %limited);
} else if($ND_boxSearchDir==2) {
$ND_boxSearchDir = 3;
ndBoxSearchAdjacentBricks(%brick, "-0.2 -0.2 0.2", %limited);
} else {
$ND_boxSearchDir = "";
$ND_boxSearchBrick = "";
return 0;
}
}
}
}
//Begin stack selection
function ND_Selection::startStackSelection(%this, %brick, %direction, %limited)
{
@ -158,7 +205,27 @@ function ND_Selection::startStackSelection(%this, %brick, %direction, %limited)
%bl_id = %this.client.bl_id;
//Add bricks connected to the first brick to queue (do not register connections yet)
if(%direction == 1)
if(%direction==2) {
while(%nextBrick = ndGetNextAdjacentBrick(%brick, %limited)) {
//If the brick is not in the list yet, add it to the queue
if($NS[%this, "I", %nextBrick] $= "")
{
if(%queueCount >= %brickLimit)
continue;
//Check trust
if(!ndTrustCheckSelect(%nextBrick, %group, %bl_id, %admin))
{
%trustFailCount++;
continue;
}
$NS[%this, "B", %queueCount] = %nextBrick;
$NS[%this, "I", %nextBrick] = %queueCount;
%queueCount++;
}
}
} else if(%direction == 1)
{
//Set lower height limit
%heightLimit = %this.minZ - 0.01;
@ -167,7 +234,6 @@ function ND_Selection::startStackSelection(%this, %brick, %direction, %limited)
for(%i = 0; %i < %upCount; %i++)
{
%nextBrick = %brick.getUpBrick(%i);
//If the brick is not in the list yet, add it to the queue
if($NS[%this, "I", %nextBrick] $= "")
{
@ -286,110 +352,137 @@ function ND_Selection::startStackSelectionAdditive(%this, %brick, %direction, %l
%admin = %this.client.isAdmin;
%group = %this.client.brickGroup.getId();
%bl_id = %this.client.bl_id;
if(%direction==2) {
%conns = 0;
while(%nextBrick = ndGetNextAdjacentBrick(%brick, %limited)) {
//If the brick is not in the list yet, add it to the queue
%nId = $NS[%this, "I", %nextBrick];
//Add bricks connected to the first brick to queue (do not register connections yet)
if(%direction == 1)
{
//Set lower height limit
%heightLimit = getWord(%brick.getWorldBox(), 2) - 0.01;
}
else
{
//Set upper height limit
%heightLimit = getWord(%brick.getWorldBox(), 5) + 0.01;
}
//Process all up bricks
%upCount = %brick.getNumUpBricks();
for(%i = 0; %i < %upCount; %i++)
{
%nextBrick = %brick.getUpBrick(%i);
//If the brick is not in the list yet, add it to the queue
%nId = $NS[%this, "I", %nextBrick];
if(%nId $= "")
{
//Don't add up bricks if we're searching down
if(%direction != 1)
continue;
if(%queueCount >= %brickLimit)
continue;
//Check trust
if(!ndTrustCheckSelect(%nextBrick, %group, %bl_id, %admin))
if(%nId $= "")
{
%trustFailCount++;
continue;
if(%queueCount >= %brickLimit)
continue;
//Check trust
if(!ndTrustCheckSelect(%nextBrick, %group, %bl_id, %admin))
{
%trustFailCount++;
continue;
}
$NS[%this, "B", %queueCount] = %nextBrick;
$NS[%this, "I", %nextBrick] = %queueCount;
%queueCount++;
}
$NS[%this, "B", %queueCount] = %nextBrick;
$NS[%this, "I", %nextBrick] = %queueCount;
%queueCount++;
}
else if(%brickIsNew)
} else {
//Add bricks connected to the first brick to queue (do not register connections yet)
if(%direction == 1)
{
//If this brick already exists, we have to add the connection now
//(Start brick won't be processed again unlike the others)
$NS[%this, "C", %brickIndex, %conns] = %nId;
%conns++;
%ci = $NS[%this, "N", %nId]++;
$NS[%this, "C", %nId, %ci - 1] = %brickIndex;
if(%ci > %this.maxConnections)
%this.maxConnections = %ci;
%this.connectionCount++;
//Set lower height limit
%heightLimit = getWord(%brick.getWorldBox(), 2) - 0.01;
}
}
//Process all down bricks
%downCount = %brick.getNumDownBricks();
for(%i = 0; %i < %downCount; %i++)
{
%nextBrick = %brick.getDownBrick(%i);
//If the brick is not in the list yet, add it to the queue
%nId = $NS[%this, "I", %nextBrick];
if(%nId $= "")
else
{
//Don't add down bricks if we're searching up
if(%direction == 1)
continue;
//Set upper height limit
%heightLimit = getWord(%brick.getWorldBox(), 5) + 0.01;
}
if(%queueCount >= %brickLimit)
continue;
//Process all up bricks
%upCount = %brick.getNumUpBricks();
//Check trust
if(!ndTrustCheckSelect(%nextBrick, %group, %bl_id, %admin))
for(%i = 0; %i < %upCount; %i++)
{
%nextBrick = %brick.getUpBrick(%i);
//If the brick is not in the list yet, add it to the queue
%nId = $NS[%this, "I", %nextBrick];
if(%nId $= "")
{
%trustFailCount++;
continue;
//Don't add up bricks if we're searching down
if(%direction != 1)
continue;
if(%queueCount >= %brickLimit)
continue;
//Check trust
if(!ndTrustCheckSelect(%nextBrick, %group, %bl_id, %admin))
{
%trustFailCount++;
continue;
}
$NS[%this, "B", %queueCount] = %nextBrick;
$NS[%this, "I", %nextBrick] = %queueCount;
%queueCount++;
}
else if(%brickIsNew)
{
//If this brick already exists, we have to add the connection now
//(Start brick won't be processed again unlike the others)
$NS[%this, "C", %brickIndex, %conns] = %nId;
%conns++;
$NS[%this, "B", %queueCount] = %nextBrick;
$NS[%this, "I", %nextBrick] = %queueCount;
%queueCount++;
%ci = $NS[%this, "N", %nId]++;
$NS[%this, "C", %nId, %ci - 1] = %brickIndex;
if(%ci > %this.maxConnections)
%this.maxConnections = %ci;
%this.connectionCount++;
}
}
else if(%brickIsNew)
//Process all down bricks
%downCount = %brick.getNumDownBricks();
for(%i = 0; %i < %downCount; %i++)
{
//If this brick already exists, we have to add the connection now
//(Start brick won't be processed again unlike the others)
$NS[%this, "C", %brickIndex, %conns] = %nId;
%conns++;
%nextBrick = %brick.getDownBrick(%i);
%ci = $NS[%this, "N", %nId]++;
$NS[%this, "C", %nId, %ci - 1] = %brickIndex;
//If the brick is not in the list yet, add it to the queue
%nId = $NS[%this, "I", %nextBrick];
if(%ci > %this.maxConnections)
%this.maxConnections = %ci;
if(%nId $= "")
{
//Don't add down bricks if we're searching up
if(%direction == 1)
continue;
%this.connectionCount++;
if(%queueCount >= %brickLimit)
continue;
//Check trust
if(!ndTrustCheckSelect(%nextBrick, %group, %bl_id, %admin))
{
%trustFailCount++;
continue;
}
$NS[%this, "B", %queueCount] = %nextBrick;
$NS[%this, "I", %nextBrick] = %queueCount;
%queueCount++;
}
else if(%brickIsNew)
{
//If this brick already exists, we have to add the connection now
//(Start brick won't be processed again unlike the others)
$NS[%this, "C", %brickIndex, %conns] = %nId;
%conns++;
%ci = $NS[%this, "N", %nId]++;
$NS[%this, "C", %nId, %ci - 1] = %brickIndex;
if(%ci > %this.maxConnections)
%this.maxConnections = %ci;
%this.connectionCount++;
}
}
}
@ -455,7 +548,8 @@ function ND_Selection::tickStackSelection(%this, %direction, %limited, %heightLi
if(!%brick)
{
messageClient(%this.client, 'MsgError', "\c0Error: \c6Queued brick does not exist anymore. Do not modify the build during selection!");
messageClient(%this.client, 'MsgError', "");
ndmessageClient(%this.client, '', "\c0Error: \c6Queued brick does not exist anymore. Do not modify the build during selection!");
%this.cancelStackSelection();
%this.client.ndSetMode(NDM_StackSelect);
@ -464,102 +558,129 @@ function ND_Selection::tickStackSelection(%this, %direction, %limited, %heightLi
ndHighlightBrick(%highlightGroup, %brick);
//Queue all up bricks
%upCount = %brick.getNumUpBricks();
%conns = 0;
if(%direction==2) {
%conns = 0;
while(%nextBrick = ndGetNextAdjacentBrick(%brick, %limited)) {
//If the brick is not in the list yet, add it to the queue
%nId = $NS[%this, "I", %nextBrick];
for(%j = 0; %j < %upCount; %j++)
{
%nextBrick = %brick.getUpBrick(%j);
//Skip bricks out of the limit
if(%limited && %direction == 0 && getWord(%nextBrick.getWorldBox(), 5) > %heightLimit)
continue;
//If the brick is not in the selection yet, add it to the queue to get an id
%nId = $NS[%this, "I", %nextBrick];
if(%nId $= "")
{
if(%queueCount >= %brickLimit)
continue;
//Check trust
if(!ndTrustCheckSelect(%nextBrick, %group, %bl_id, %admin))
if(%nId $= "")
{
%trustFailCount++;
if(%queueCount >= %brickLimit)
continue;
//Check trust
if(!ndTrustCheckSelect(%nextBrick, %group, %bl_id, %admin))
{
%trustFailCount++;
continue;
}
$NS[%this, "B", %queueCount] = %nextBrick;
$NS[%this, "I", %nextBrick] = %queueCount;
%queueCount++;
}
}
} else {
//Queue all up bricks
%upCount = %brick.getNumUpBricks();
%conns = 0;
for(%j = 0; %j < %upCount; %j++)
{
%nextBrick = %brick.getUpBrick(%j);
//Skip bricks out of the limit
if(%limited && %direction == 0 && getWord(%nextBrick.getWorldBox(), 5) > %heightLimit)
continue;
//If the brick is not in the selection yet, add it to the queue to get an id
%nId = $NS[%this, "I", %nextBrick];
if(%nId $= "")
{
if(%queueCount >= %brickLimit)
continue;
//Check trust
if(!ndTrustCheckSelect(%nextBrick, %group, %bl_id, %admin))
{
%trustFailCount++;
continue;
}
$NS[%this, "B", %queueCount] = %nextBrick;
$NS[%this, "I", %nextBrick] = %queueCount;
%nId = %queueCount;
%queueCount++;
}
$NS[%this, "B", %queueCount] = %nextBrick;
$NS[%this, "I", %nextBrick] = %queueCount;
%nId = %queueCount;
%queueCount++;
}
$NS[%this, "C", %i, %conns] = %nId;
%conns++;
$NS[%this, "C", %i, %conns] = %nId;
%conns++;
//If this brick is from a previous stack selection,
//we need to link the connection back as well
if(%nId < %selectionStart)
{
%ci = $NS[%this, "N", %nId]++;
$NS[%this, "C", %nId, %ci - 1] = %i;
if(%ci > %this.maxConnections)
%this.maxConnections = %ci;
%this.connectionCount++;
}
}
//Queue all down bricks
%downCount = %brick.getNumDownBricks();
for(%j = 0; %j < %downCount; %j++)
{
%nextBrick = %brick.getDownBrick(%j);
//Skip bricks out of the limit
if(%limited && %direction == 1 && getWord(%nextBrick.getWorldBox(), 2) < %heightLimit)
continue;
//If the brick is not in the selection yet, add it to the queue to get an id
%nId = $NS[%this, "I", %nextBrick];
if(%nId $= "")
{
if(%queueCount >= %brickLimit)
continue;
//Check trust
if(!ndTrustCheckSelect(%nextBrick, %group, %bl_id, %admin))
//If this brick is from a previous stack selection,
//we need to link the connection back as well
if(%nId < %selectionStart)
{
%trustFailCount++;
%ci = $NS[%this, "N", %nId]++;
$NS[%this, "C", %nId, %ci - 1] = %i;
if(%ci > %this.maxConnections)
%this.maxConnections = %ci;
%this.connectionCount++;
}
}
//Queue all down bricks
%downCount = %brick.getNumDownBricks();
for(%j = 0; %j < %downCount; %j++)
{
%nextBrick = %brick.getDownBrick(%j);
//Skip bricks out of the limit
if(%limited && %direction == 1 && getWord(%nextBrick.getWorldBox(), 2) < %heightLimit)
continue;
//If the brick is not in the selection yet, add it to the queue to get an id
%nId = $NS[%this, "I", %nextBrick];
if(%nId $= "")
{
if(%queueCount >= %brickLimit)
continue;
//Check trust
if(!ndTrustCheckSelect(%nextBrick, %group, %bl_id, %admin))
{
%trustFailCount++;
continue;
}
$NS[%this, "B", %queueCount] = %nextBrick;
$NS[%this, "I", %nextBrick] = %queueCount;
%nId = %queueCount;
%queueCount++;
}
$NS[%this, "B", %queueCount] = %nextBrick;
$NS[%this, "I", %nextBrick] = %queueCount;
%nId = %queueCount;
%queueCount++;
}
$NS[%this, "C", %i, %conns] = %nId;
%conns++;
$NS[%this, "C", %i, %conns] = %nId;
%conns++;
//If this brick is from a previous stack selection,
//we need to link the connection back as well
if(%nId < %selectionStart)
{
%ci = $NS[%this, "N", %nId]++;
$NS[%this, "C", %nId, %ci - 1] = %i;
//If this brick is from a previous stack selection,
//we need to link the connection back as well
if(%nId < %selectionStart)
{
%ci = $NS[%this, "N", %nId]++;
$NS[%this, "C", %nId, %ci - 1] = %i;
if(%ci > %this.maxConnections)
%this.maxConnections = %ci;
if(%ci > %this.maxConnections)
%this.maxConnections = %ci;
%this.connectionCount++;
%this.connectionCount++;
}
}
}
@ -895,7 +1016,8 @@ function ND_Selection::tickBoxSelectionProcess(%this)
if(!%brick)
{
messageClient(%this.client, 'MsgError', "\c0Error: \c6Queued brick does not exist anymore. Do not modify the build during selection!");
messageClient(%this.client, 'MsgError', "");
ndmessageClient(%this.client, '', "\c0Error: \c6Queued brick does not exist anymore. Do not modify the build during selection!");
%this.cancelBoxSelection();
%this.client.ndSetMode(NDM_BoxSelect);
@ -1016,6 +1138,9 @@ function ND_Selection::recordBrickData(%this, %i)
//Rotation
$NS[%this, "R", %i] = %brick.angleID;
//Owner
$NS[%this, "O", %i] = %brick.getGroup().bl_id;
//Colors
if($NDHN[%brick])
{
@ -1588,7 +1713,7 @@ function ND_Selection::finishSuperCut(%this)
%this.client.fillBricksAfterSuperCut = false;
if(%this.trustFailCount)
messageClient(%this.client, '', "\c6Cannot run fill bricks, you do not have enough trust bricks already in the area.");
ndmessageClient(%this.client, '', "\c6Cannot run fill bricks, you do not have enough trust bricks already in the area.");
else
%this.client.doFillBricks(%this.client.NDFillBrickSubset);
}
@ -2070,9 +2195,10 @@ function ND_Selection::getGhostWorldBox(%this)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Start planting bricks!
function ND_Selection::startPlant(%this, %position, %angleID, %forcePlant)
function ND_Selection::startPlant(%this, %position, %angleID, %forcePlant, %ownership)
{
%this.forcePlant = %forcePlant;
%this.ownership = %ownership;
%this.plantSearchIndex = 0;
%this.plantQueueIndex = 0;
@ -2349,6 +2475,29 @@ function ND_Selection::tickPlantTree(%this, %remainingPlants, %position, %angleI
%this.plantSchedule = %this.schedule(30, tickPlantTree, $Pref::Server::ND::ProcessPerTick, %position, %angleID);
}
function ndBrickGroupFromBlid(%blid) {
%bg = "BrickGroup_" @ %blid;
if (isObject(%bg)) {
return %bg.getId();
} else {
%bg = new SimGroup("BrickGroup_" @ %blid){};
%bg.client = 0;
%bg.name = "\c2BL_ID: " @ %blid @ "\c2\c1";
%bg.bl_id = %blid;
mainBrickGroup.add(%bg);
return %bg.getId();
}
}
function ndFindWord(%s, %w, %x, %a) {
if(%a $= "") %a = 1;
%c = getWordCount(%str);
for(%i = %x+0; %i<%c; %i+=%a) {
if(getWord(%s, %i) $= %w) return %i;
}
return -1;
}
//Attempt to plant brick with id %i
//Returns brick if planted, 0 if floating, -1 if blocked, -2 if trust failure
function ND_Selection::plantBrick(%this, %i, %position, %angleID, %brickGroup, %client, %bl_id)
@ -2549,7 +2698,12 @@ function ND_Selection::plantBrick(%this, %i, %position, %angleID, %brickGroup, %
$LastLoadedBrick = %brick;
//Add to brickgroup
%brickGroup.add(%brick);
//%brickGroup.add(%brick);
if(%this.ownership && $NS[%this, "O", %i] !$= "") {
ndBrickGroupFromBlid($NS[%this, "O", %i]).add(%brick);
} else {
%brickGroup.add(%brick);
}
//Attempt plant
%error = %brick.plant();
@ -2728,8 +2882,9 @@ function ND_Selection::plantBrick(%this, %i, %position, %angleID, %brickGroup, %
%param = ndRotateVector(%param, %angleID);
case "list":
%value = getWord(%paramType, %param * 2 + 1);
//%value = getWord(%paramType, %param * 2 + 1);
%value = getWord(%paramType, ndFindWord(%paramType, %param, 2, 2)-1);
switch$(%value)
{
case "Up": %dir = 0;
@ -2743,6 +2898,8 @@ function ND_Selection::plantBrick(%this, %i, %position, %angleID, %brickGroup, %
if(%dir >= 0)
{
%oldvalue = %value;
%oldparam = %param;
switch(ndTransformDirection(%dir, %angleID, %mirrX, %mirrY, %mirrZ))
{
case 0: %value = "Up";
@ -2753,14 +2910,15 @@ function ND_Selection::plantBrick(%this, %i, %position, %angleID, %brickGroup, %
case 5: %value = "West";
}
for(%l = 1; %l < getWordCount(%paramType); %l += 2)
{
if(getWord(%paramType, %l) $= %value)
{
%param = getWord(%paramType, %l + 1);
break;
}
}
//for(%l = 1; %l < getWordCount(%paramType); %l += 2)
//{
// if(getWord(%paramType, %l) $= %value)
// {
// %param = getWord(%paramType, %l + 1);
// break;
// }
//}
%param = getWord(%paramType, ndFindWord(%paramType, %value, 1, 2)+1);
}
}
}
@ -2814,7 +2972,7 @@ function ND_Selection::finishPlant(%this)
{
//Report mirror errors
if($NS[%this.client, "MXC"] > 0 || $NS[%this.client, "MZC"] > 0)
messageClient(%this.client, '', "\c6Some bricks were probably mirrored incorrectly. Say \c3/mirErrors\c6 to find out more.");
ndMessageClient(%this.client, '', "\c6Some bricks were probably mirrored incorrectly. Say \c3/mirErrors\c6 to find out more.");
%count = %this.brickCount;
%planted = %this.plantSuccessCount;
@ -3572,6 +3730,11 @@ function ND_Selection::tickSaveBricks(%this)
SPC !$NS[%this, "NC", %i]
SPC !$NS[%this, "NR", %i]
);
// Write ownership
if($NS[%this, "O", %i] !$= "") {
%file.writeLine("+-OWNER " @ $NS[%this, "O", %i]);
}
//Write brick name
if((%tmp = $NS[%this, "NT", %i]) !$= "")
@ -3849,7 +4012,8 @@ function ND_Selection::finishSaving(%this)
%s1 = %this.brickCount == 1 ? "" : "s";
%s2 = %this.connectionCount == 1 ? "" : "s";
messageClient(%this.client, 'MsgProcessComplete', "\c6Finished saving selection, wrote \c3"
messageClient(%this.client, 'MsgProcessComplete');
ndmessageClient(%this.client, '', "\c6Finished saving selection, wrote \c3"
@ %this.brickCount @ "\c6 Brick" @ %s1 @ " with \c3" @ %this.connectionCount @ "\c6 Connection" @ %s2 @ "!");
%this.client.ndLastSaveTime = $Sim::Time;
@ -4151,10 +4315,12 @@ function ND_Selection::tickLoadBricks(%this)
warn("LOAD DUP: Got connection data before connection sizes");
//Line is irrelevant
//Line is owner
case "+-OWNER":
%nothing = "";
//%ownerBlid = trim(getSubStr(%line, 7, strLen(%line)-7));
%ownerBlid = getWord(%line, 1);
%ownerBlid = mAbs(mFloor(%ownerBlid));
$NS[%this, "O", %index] = %ownerBlid;
//Line is brick
default:
@ -4475,7 +4641,8 @@ function ND_Selection::finishLoading(%this)
%s1 = %this.brickCount == 1 ? "" : "s";
%s2 = %this.connectionCount == 1 ? "" : "s";
messageClient(%this.client, 'MsgProcessComplete', "\c6Finished loading selection, got \c3"
messageClient(%this.client, 'MsgProcessComplete', "");
ndmessageClient(%this.client, '', "\c6Finished loading selection, got \c3"
@ %this.brickCount @ "\c6 Brick" @ %s1 @ " with \c3" @ %this.connectionCount @ "\c6 Connection" @ %s2 @ "!");
%this.client.ndLastLoadTime = $Sim::Time;