Author Topic: Spreading bricks  (Read 627 times)

I dont really get how i could do this.. What i want is that if there is nothing in a space, it makes a new 1x1 brick there. I know how to make the bricks spread, but it overlaps stuff. Can i get help to make it only make the brick if there isnt already something there?

You would need one of the container searches with an appropriate mask. Raycast tends to work best, as some/all of the others don't check the geometry(or at least not as well as raycast, leading to the entire interior of the bedroom, even the hollow parts, showing up as solid)

I have no idea what AP just said... :cookieMonster:

However, I do need this, and indeed, brick spreading aswell, for a script of my own that I'm working on.

Note: Ignore this. I realized a better solution, and wrote it at the bottom.

Look up ContainerRayCast on page 267 of the guide mentioned here.

There are three required parameters:

The first two are the start and end positions, you send them as XYZ vectors where the X, the Y, and the Z are separated by spaces (%x SPC %y SPC %z)

The third argument is rather different, it's a number created through a binary or (|) of various typemasks. (If you want everything, use $TypeMasks::All. But that includes cameras, corpses, bricks with raycasting disabled, and countless other things.)

To see all available typemasks, use the following console command:
export("$typemasks::*");
Use the variable, not the number itself.

Sample:
$TypeMasks::FxBrickAlwaysObjectType | $TypeMasks::InteriorObjectType | $TypeMasks::TerrainObjectType

Then you can optionally include up to 6 objects for it to ignore.

To use it to see if a brick can be placed, it would probably work best to raycast from the bottom to the top of where the brick would be placed for every plate. There is probably a better way within the base implementation of brick planting, but that unfortunately happens to be in a .dso.



Actually, there might be an even simpler solution: Try to plant it normally, and if the error is anything except floating, there is something there already.

Still don't understand you :D

%brick.plant() returns an error.

Check that error.

If it is neither the error for floating (mid-air) or no error at all, it was being planted in something solid.


If you don't want it planting on players, vehicles, or items as well, then you need to learn about container searches, and that is too advanced to cover here.

Hmm, okay.
What are the br-- Nevermind I can use dump(); for that.