Author Topic: Planting bricks codewise cause plant errors - Solved!  (Read 1018 times)

What I'm doing:

I am planting a brick on top of the other. 2x2, 4x4, 4x4. They all plant successfully. NOW, if via code I plant a second set of bricks 2x2, 4x4, 4x4, with enough space for it to plant successfully, it won't plant and return 1. I played around with my temp brick, the errors are as follow:

0 - No error.
1 - Overlap.
2 - Float.
3 - Stuck.
5 - Buried.

Why would it return Overlap if there's enough room for the brick to plant? Planting it manually via the console also returns 1. The same occurs when leaving a 1x space inbetween the bricks. Help please. I'd post images but I do not have the bandwidth to upload them although I'll try if it's absolutely necessary.
« Last Edit: January 01, 2016, 08:50:18 AM by Pastrey Crust »

You'll want to align the brick's position to the grid. Although the brick will appear aligned to the grid automatically, and may even behave properly, but if it's position isn't set exactly right then it's going to cause problems.

Try %brick.setTrusted(true); right before %brick.plant();

I'm pretty sure the bricks are aligned to the grid properly. Planting the bricks manually and by code return the same positions. I tried adding %newbrick.setTrusted(1); before %newbrick.plant(); but no change. Also worth adding that this only happens when planted next to bricks planted by code. Making a tight space manually will not trigger this bug. No, never mind. It didn't trigger with the window brick but it does with other bricks.
« Last Edit: December 31, 2015, 06:47:41 PM by Pastrey Crust »

A brick you planted before was not setTrusted(true);. I've had this exact same problem when writing the duplicator.

I've got this.    %newbrick.setTrusted(1);
   %newbrick.plant();

All of the ones planted via script have been setTrusted();

However, I am unsure about the ones I plant myself.



As I understand it, this is all you need for planting bricks. This code will add them to the the server's brickgroup, IE: BL_ID 888888
view on Pastebin

Code: [Select]
function createBrick(%client, %pos, %data, %angleID, %baseplate, %color, %colorFX, %shapeFX, %isRaycasting, %isColliding, %isRendering)
{
%brick = new fxDTSBrick()
{
client = %client;
position = %pos;
datablock = %data;
angleID = %angleID;
isBasePlate = %baseplate;
colorID = %color;
colorFX = %colorFX;
shapeFX = %shapeFX;
isRaycasting = %isRaycasting;
isColliding = %isColliding;
isRendering = %isRendering;
isPlanted = 1;
};

%error = %brick.plant();

if(%error != 0)
{
%brick.delete();
return;
}

%brick.setTrusted(1);
BrickGroup_888888.add(%brick);

return %brick;
}
« Last Edit: January 01, 2016, 08:21:55 AM by Darksaber2213 »

I've tried everything posted in the thread (even though it was basically the same) but both Dark's and Dannu's codes do not have error handling for error=1. Zeblote's error handling is for error=2. I'm getting error=1 which would be overlap based on what I found before.

I seem to have left out some important code. Specifically the whole "rotation" field. Please revise.
If I remember correctly, this was a problem for me in the past. However, I remember fixing it with this code.

The pastebin has also been updated.

Code: [Select]
function createBrick(%client, %pos, %data, %angleID, %baseplate, %color, %colorFX, %shapeFX, %isRaycasting, %isColliding, %isRendering)
{
%brick = new fxDTSBrick()
{
client = %client;
position = %pos;
datablock = %data;
angleID = %angleID;
rotation = rotationFromAngleID(%angleID);
isBaseplate = %baseplate;
colorID = %color;
colorFX = %colorFX;
shapeFX = %shapeFX;
isRendering = %isRendering;
isColliding = %isColliding;
isRaycasting = %isRaycasting;
isPlanted = 1;
};

%error = %brick.plant();

if(%error == 1 || %error == 5 || %error == 3)
{
%brick.delete();
return;
}

%brick.setTrusted(1);
BrickGroup_888888.add(%brick);

%brick.setRendering(%brick.isRendering);
%brick.setRayCasting(%brick.isRaycasting);
%brick.setColliding(%brick.isColliding);
%brick.setColorFX(%brick.colorFX);

return %brick;
}

function rotationFromAngleID(%angle)
{
switch(%angle)
{
case 0:
%rotation = "1 0 0 0";
case 1:
%rotation = "0 0 1 90";
case 2:
%rotation = "0 0 1 180";
default:
%rotation = "0 0 -1 90";
}
return %rotation;
}
« Last Edit: January 01, 2016, 08:35:53 AM by Darksaber2213 »

I've got this.
Code: [Select]
brick[3, 0] = "brick4x4Data 0 0 1.6 0 0 -1 90.0002 32 0 0";
Maybe the 90.0002 is the culprit. Checking now.

I'm getting weirdass values in the rotation field.
"0 0 -1 116.62"
"0 0 -1 95.86"
« Last Edit: January 01, 2016, 08:45:03 AM by Pastrey Crust »

There we go! The rotations were being bitchy! Thanks for teaching me about the angleID field! Case closed!