Author Topic: Spawning a brick directly above another  (Read 1013 times)

How would I spawn a brick directly above another spawned brick via script?

I know how to spawn a brick and change its position in all axes but is there a good way to spawn a brick on top of another, other than
changing its z axis.

but is there a good way to spawn a brick on top of another, other than changing its z axis.
no i dont believe so


Code: [Select]
function fxDTSbrick::UpDuplicate(%this)
{
%zsize = %this.getDatablock().brickSizeZ * 0.2;
%pos = vectorAdd(%this.getPosition(), "0 0 " @ %zsize);
%brick = new FxDTSbrick()
{
datablock = %this.getDatablock();
position = %pos;
rotation = %this.rotation;
colorID = %this.colorID;
scale = "1 1 1";
angleID = %this.angleID;
colorFxID = %this.colorFxID;
shapeFxID = %this.shapeFxID;
isPlanted = 1;
client = %this.client;
};
%brick.plant();
%brick.setTrusted(1);
if(isObject(%this.getGroup()))
{
%this.getGroup().add(%brick);
}
$Server::BrickCount++;
return %brick;
}

Shouldn't you set the brick to trusted before planting it or does it not make a difference?

Shouldn't you set the brick to trusted before planting it or does it not make a difference?
I can't imagine it would matter.

Thanks Amade that works for the z.

Would it be possible to do the same for x and y too.

(i tried with bricksizex * 0.2 but it didnt seems to work like bricksizez * 0.2)

Thanks Amade that works for the z.

Would it be possible to do the same for x and y too.

(i tried with bricksizex * 0.2 but it didnt seems to work like bricksizez * 0.2)
yes

Code: [Select]
function fxDTSbrick::UpDuplicate(%this)
{
%xsize = %this.getDatablock().brickSizeX * 0.2;
%pos = vectorAdd(%this.getPosition(), %xsize SPC "0 0");
%brick = new FxDTSbrick()
{
datablock = %this.getDatablock();
position = %pos;
rotation = %this.rotation;
colorID = %this.colorID;
scale = "1 1 1";
angleID = %this.angleID;
colorFxID = %this.colorFxID;
shapeFxID = %this.shapeFxID;
isPlanted = 1;
client = %this.client;
};
%brick.plant();
%brick.setTrusted(1);
if(isObject(%this.getGroup()))
{
%this.getGroup().add(%brick);
}
$Server::BrickCount++;
return %brick;
}


In the line %xsize = %this.getDatablock().brickSizeX * 0.2; you need to change that 0.2 to a 0.5 if you're not using the Z axis, or it won't line up right (especially for larger bricks).

The new height must be the sum of half of each of the bricks' height.