Author Topic: Planting floating bricks  (Read 3011 times)

How do you check if it's inside a brick?
when you try to plant it'll give a certain number that cooresponds to the error

when you try to plant it'll give a certain number that cooresponds to the error
Actually no, when placing them through script the creation of the brick would usually occur anyways even if there was an overlap. I just had to write my code to ensure there was never any overlaps. Although I believe you can do something with isContainerBoxClear to check if bricks are in a particular spot.

Actually no, when placing them through script the creation of the brick would usually occur anyways even if there was an overlap. I just had to write my code to ensure there was never any overlaps. Although I believe you can do something with isContainerBoxClear to check if bricks are in a particular spot.
Thanks Port, I found it. :)
ContainerBoxEmpty( mask , location , xRadius [ , yRadius , zRadius ] )

Thanks Port, I found it. :)
ContainerBoxEmpty( mask , location , xRadius [ , yRadius , zRadius ] )
wtf when did this function exist i swear to god i looked for this exact thing ages ago and didn't find it and i asked here and someone made a function to do it

wtf when did this function exist i swear to god i looked for this exact thing ages ago and didn't find it and i asked here and someone made a function to do it
Google is your friend.

wtf when did this function exist i swear to god i looked for this exact thing ages ago and didn't find it and i asked here and someone made a function to do it

It really doesn't work.


It doesn't? D:
It does... kinda.

It works intermittently.

Look in the Player Persistence code for reference, it's used there to check if where a player is spawning is covered with bricks. It works to some extent, but (as you might have seen through experience of players spawning in bricks) it's not perfect.
« Last Edit: January 08, 2014, 03:11:45 PM by Pecon »

What's the difference between that function and evaluating containerFindFirst?

What's the difference between that function and evaluating containerFindFirst?
It searches in a rectangular prism instead of a sphere.

It searches in a rectangular prism instead of a sphere.
I'm not sure that's true...
I've always used containerFindFirst, never had a problem with it not working properly

Oh, oops. I was thinking of containerRadius. In that case, it's just a function that works for a more specific purpose.

They're both absurdly messed up. x/y/zRadius is not in Torque units, and modifying any of the three coordinates will implicitly modify all the others (it's even more broken than the boundingBox field on player datablocks, somehow). Not to mention that box searches usually never find anything correctly even with a huge search radius.

Google is your friend.
a lot of the time i find you're better off looking around here for TS stuff (or bl-related things)

we're a p big (and active) source of information for this era of torque and a lot of time when you search for things about TS, topics from coding help end up in the top results. most of the time when you find garagegames pages, they're for T3D, and things have changed since our version of torque. granted, a lot of things are similar

i generally only google general torque issues just to try and solve issues myself before asking for help
« Last Edit: January 10, 2014, 07:04:06 PM by otto-san »

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")
{
if(%client.player.tempBrick.checkPlantingError() == -1)
{
parent::serverCmdPlantBrick(%client);

return;
}

%client.player.tempBrick.setName("CopyBrick");

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

eval("BrickGroup_" @ %client.bl_id @ ".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";
}
}
Change eval("BrickGroup_" @ %client.bl_id @ ".add(" @ %brick @ ");"); to %brickGroup = "BrickGroup_" @ %client.bl_id; %brickGroup.add(%brick);
Thx.