add box features
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user