Author Topic: How do you spawn bricks with a script?  (Read 618 times)

The title.

How would I use a script to spawn in a brick? I already tried this

%posx = 60;
%posy = 0;
%posz = 1;
%tmp = new fxDTSBrick()
{
    datablock = "brick2x2Data";
    position = %posx SPC %posy SPC %posz;
    rotation = "0 0 0 0"; colorID = "1";
    scale = "1 1 1"; angleID = "0";
    colorfxID = "0"; shapefxID = "0";
    isPlanted = 1;
};

It spawns the brick, but the physics are all crazy, you can't use tools on it, and you can't even get its ID.

How would I spawn a brick in that had all the properties of a regular brick?

well first your coordinate has to be valid for the brick you're planting. the position is the center of the brick, whch can be a non-multiple of 0.5 or 0.2 depending on the brick.

then after creating the brick you need to call %brick.plant();, which will return an integer based on what error (if any) was found when attempting to plant the brick

I suggest you get a copy of eval from someone and learn how to use it so you can check the values of bricks ingame and see how their fields are formatted.
« Last Edit: June 29, 2016, 05:27:30 PM by Conan »

Thanks for you help, it works now.
But now there is another problem. If I try to destroy it using a hammer it gives me an error:

SimGroup::getTrustFaliureMessage(MissionCleanUp [BrickID]) - brickgroup is not in the main brick group


You will want to add the brick to the brick group that you want using brickGroup_ID.add(%brick);, where the ID is the BL_ID, and %brick is the actual brick object (obviously)
« Last Edit: June 29, 2016, 06:15:18 PM by Cruxeis »