Author Topic: [Solved] Detecting whether a brick can be placed or not  (Read 1065 times)

Is there a simple way to do this? I have searched and looked at trace logs but I can't seem to figure it out.
« Last Edit: January 27, 2016, 10:07:06 AM by Dr.Tyler O. »

What exactly do you want to do?

%brick.plant(); will return stuff to check with. I forget what each value pertains to, but I know 0 is no error and 2 is floating.
https://github.com/TheBlackParrot/blockland-brickochet/blob/master/build.cs

What exactly do you want to do?

Detect whether a brick can be planted or not. TheBlackParrot has the right idea.

%brick.plant(); will return stuff to check with. I forget what each value pertains to, but I know 0 is no error and 2 is floating.

Perhaps I don't understand what you're implying here. I took a look at the github and did a quick test in game.

Apparently it isn't as easy as:
Code: [Select]
if(%client.player.tempBrick.plant() == 0)
The code above works but it breaks my ghost brick so I can't move it or anything until I clear it and place another.
« Last Edit: January 26, 2016, 05:40:46 PM by Dr.Tyler O. »

The tempbrick is a separate entity if I remember right, you have to clone it.

The tempbrick is a separate entity if I remember right, you have to clone it.
How would I go about doing that?

Code: [Select]
function player::canPlantTempBrick(%player)
{
if(!isObject(%temp = %player.tempBrick))
{
return;
}

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

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

if(!%error)
{
return true;
}

return false;
}

This became way more complicated than it had to be. I fixed it simply by detecting if the last brick that I attempted to place was actually planted or not.

Code: [Select]
if(%brick.isPlanted)
I apologize guys, thanks for your help anyway.  :cookieMonster:
« Last Edit: January 27, 2016, 10:13:24 AM by Dr.Tyler O. »

I played around with my temp brick, the errors are as follow:

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