Author Topic: Planting floating bricks  (Read 3009 times)

I'm running into the same issue that Port had: http://forum.blockland.us/index.php?topic=206705.0

Any solutions?

I guess since you looked at that topic you've already tried limiting the number of bricks placed every X amount of time?

Try packaging plant(), making it return 0 instead of what ever the float error is (2?)

Actually, it's not just floating bricks, it's any bricks.

They either A) do not plant at all, or B) look like they are planted but have no collision or anything. /getID also does not work on them.

This is the code where I plant them:
Code: [Select]
%newBrick = new fxDtsBrick()
{
angleID = %bottomBrick.angleID;
client = clientGroup.getObject(0);
colorID = %bottomBrick.colorID;
dataBlock = %newDataBlock;
isBasePlate = %bottomBrick.isBasePlate;
position = %pos;
rotation = %bottomBrick.rotation;

isPlanted = true;
};
%newBrick.plant();

%stack.brickGroup.add(%newBrick);

try running ::dump() on the "planted" collisionless bricks

Here you go:

Quote
==>optimizebrickgroup(brickgroup_999999);
==>brickgroup_999999.listobjects();
   475103: fxDTSBrick
==>475103.dump();
Member Fields:
  angleID = "2"
  client = "24571"
  colorFxID = "0"
  colorID = "0"
  dataBlock = "brick4x4x30Data"
  isBasePlate = "1"
  isPlanted = "1"
  position = "287.5 581 3"
  printID = "0"
  rotation = "0 0 1 180"
  scale = "1 1 1"
  shapeFxID = "0"
  stackBL_ID = "-1"
Tagged Fields:
Methods:
//snip - removed methods


I see nothing unusual.
« Last Edit: January 07, 2014, 10:44:44 PM by Greek2me »

Try comparing the tagged fields of that one to the tagged fields of a normally planted brick

Check what's different maybe

Try setting the stackBL_ID, it's something dumb like that that makes it not work.

I'm pretty sure I got this working right at some point, I'll look into it when I can.

Here's what I use to enable players to place floating bricks. It works perfectly. They all have collision, raycasting, and all that good stuff.
Code: [Select]
package BrickHax
{
function serverCmdPlantBrick(%client)
{
if(%client.player.tempBrick.checkPlantingError() $= "float")
{
%client.player.tempBrick.setName("CopyBrick");

%brick = new fxDTSBrick(CopiedBrick : CopyBrick)
{
client = %client;
isPlanted = 1;
};

%brickGroup = "BrickGroup_" @ %client.bl_id;
%brickGroup.add(%brick);
%brick.plant();
%brick.playSound(clickPlantSound);
%brick.setTrusted(1);
%client.undoStack.head++;
eval("%client.undoStack.val" @ %client.undoStack.head @ " = \"" @ %brick @ "\tPLANT\";");
%brick.setName("");
%client.player.tempBrick.setName("");
}

else
{
parent::serverCmdPlantBrick(%client);
}
}
};
activatePackage(BrickHax);

function fxDTSBrick::checkPlantingError(%temp)
{
if(%temp.isPlanted())
{
error("You must use a temp brick. Not a brick!");

return -1;
}

%brick = new fxDTSBrick()
{
datablock = %temp.getDatablock();
position = %temp.getPosition();
rotation = getWords(%temp.getTransform(), 3, 6);
};

%error = %brick.plant();
%brick.delete();

switch$(%error)
{
case 0: return 0;

case 1: return "overlap";

case 2: return "float";

case 5: return "buried";
}
}
« Last Edit: January 11, 2014, 08:15:50 AM by jes00 »

That's something else though. He isn't trying to hackishly get players to be able to build floating bricks, he's trying to place them by script without such a complicated method.

I usually use the following function

Code: [Select]
function createBrick(%cl, %data, %pos, %color, %angleID)
{
if(!isObject(%data) || %data.getClassName() !$= "fxDTSBrickData")
return -1;
if(getWordCount(%pos) != 3)
return -1;
if(%angleID $= "")
%angleID = 0;
if(isObject(%cl) && (%cl.getClassName() $= "GameConnection" | %cl.getClassName() $= "AIConnection"))
{
%blid = %cl.bl_id;
if(%blid $= "")
%blid = -1;
%flag = 1;
}
else if(isObject(%cl) && %cl.getClassName() $= "SimGroup" && MainBrickgroup.isMember(%cl))
{
%group = %cl;
%cl = %group.client;
%blid = %group.bl_id;
}
else %cl = 0;
switch(%angleID)
{
case 0: %rot = "1 0 0 0";
case 1: %rot = "0 0 1 90";
case 2: %rot = "0 0 1 180";
case 3: %rot = "0 0 -1 90";
}
(%brick = new fxDtsBrick()
{
client = %cl;
colorFxID = 0;
colorID = %color;
datablock = %data;
isPlanted = 1;
position = getWord(%pos, 0) SPC getWord(%pos, 1) SPC getWord(%pos, 2);
rotation = %rot;
shapeFxID = 0;
stackBL_ID = %blid;
}).angleID = %angleID;
%err = %brick.plant();
%brick.setTrusted(1);
missionCleanup.add(%brick);
if(%flag) %cl.brickgroup.add(%brick);
else if(isObject(%group)) %group.add(%brick);
return %brick TAB %err;
}

Returns the brick and the error, if any. The angleID is defined outside the brick itself because it solved an issue where the brick wouldn't rotate at all. Weirdness.


Usage: %data = createBrick(brickgroupOrClient, fxDtsBrickData, position, colorID, angleID);

It's still not working. The few bricks that it does decide to plant have strange issues where you can walk/shoot through them and random faces don't show up.

This is the code: http://pastebin.com/swPFvNpb
It's designed for Treynold's terrain-to-bricks converter.

I had this issue while making my dungeon generator. I've fixed it first by making certain that no bricks are underground or are stuck inside each other, and second by not using events to plant them (<-- Still uncertain as to why this was problematic).

I had this issue while making my dungeon generator. I've fixed it first by making certain that no bricks are underground or are stuck inside each other, and second by not using events to plant them (<-- Still uncertain as to why this was problematic).
How do you check if it's inside a brick?