i think his point is to reference that code to relearn how to place bricks, thinking that the code in gsf's terrain generator is simple. its very much not - despite the terrain gen being rather simple, doing anything as complicated as that in ts is incredibly difficult/annoying due to the slow performance of ts and lack of basic language features like arrays.
you can place bricks via creating
new fxDTSBrick() object instances, assigning them a datablock, position, and rotation. if you give an invalid position it will actually helpfully auto-snap to a valid position.... but not necessarily the closest one (ie you need to make your own position rounding function). brick positions are set at the center of their bounding box, and the grid is 0.5x0.5x0.2 per 1x1f
ex:
valid position for a 1x1: | 0.25 0.25 0.3 |
valid position for a 1x2: | 0.25 0.5 0.3 |
valid position for a 2x2f: | 0 0 0.1 |
valid position for a 2x2x2 plate tall: | 0.5 25.5 0.2 |
valid rotations:
function getRandomBrickOrthoRot()
{
%rand = getRandom(0, 3);
switch (%rand)
{
case 0: return "1 0 0 0";
case 1: return "0 0 1 " @ 90;
case 2: return "0 0 1 " @ 180;
case 3: return "0 0 -1 " @ 90;
}
}
once creating the brick, run
%brick.plant(); and capture the output for errors. error codes:
case 0: return 0;
case 1: return "overlap";
case 2: return "float";
case 3: return "stuck";
case 4: return "unstable";
case 5: return "buried";
note that trust is NOT checked here. you'll have to do that manually if you care about trust - use `getTrustLevel(%obj1, %obj2);` to check that (0 for none, 1 for build, 2 for full, 3 for self-owned)
after that, run
%brick.setTrusted(1);. this does not actually check trust - this just makes it possible to plant bricks horizontally around it properly. not sure why its in the game but it is and you need to run it if you want people to be able to plant bricks around it.
some key notes:
if you dont care about saving/loading the bricks, or will override
.plant(); to always return 0, you can actually just straight up ignore plant errors and the bricks will collide and work just fine after running
.plant();.
similar goes for
.setTrusted();