Blockland Forums > Modification Help

Checking if a position has brick or not?

Pages: (1/2) > >>

Space Man:

How would I check if the wanted position has a brick or not?

Slicksilver:

You have to use a raycast to do this. I personally have had issues with normal raycasts, so I like to use box raycasts.


--- Code: ---function getBrickAtPos(%pos)
{
initContainerBoxSearch(%pos, "0.4 0.4 0.2", $typeMasks::FxBrickAlwaysObjectType);
%brick = containerSearchNext();
if(isObject(%brick))
return %brick;
return 0;
}

--- End code ---


otto-san:


--- Quote from: Slicksilver on February 23, 2012, 02:10:20 PM ---
--- Code: ---function getBrickAtPos(%pos)
{
initContainerBoxSearch(%pos, "0.5 0.5 0.3", $typeMasks::FxBrickAlwaysObjectType);
%brick = containerSearchNext();
if(isObject(%brick))
return %brick;
return 0;
}

--- End code ---

--- End quote ---
With that code, wouldn't it return the first brick it finds that's also at the sides?

I remember having issues with that. The search seems to do a bit of a wider area by a small amount.

I may be wrong though. I just remember that being an issue.

Slicksilver:


--- Quote from: otto-san on February 23, 2012, 05:58:48 PM ---With that code, wouldn't it return the first brick it finds that's also at the sides?

I remember having issues with that. The search seems to do a bit of a wider area by a small amount.

I may be wrong though. I just remember that being an issue.

--- End quote ---
It should still get the brick inside it anyway. Oh well, I'll make the search box a teensy bit smaller.

otto-san:


--- Quote from: Slicksilver on February 23, 2012, 09:16:23 PM ---It should still get the brick inside it anyway. Oh well, I'll make the search box a teensy bit smaller.

--- End quote ---
From what I remember, if you literally make it 0.0001 smaller on all axes it works.

Pages: (1/2) > >>

Go to full version