Author Topic: How do I make a brick?  (Read 990 times)

Yeah, how do I make a brick through code? I'm planning on making a Risk-like Gamemode and I need to know how to make bricks through code.



Code: [Select]
$Mining::Host = new ScriptObject()
{

isAdmin = 1;
brickgroup = 0;
bl_id = getNumKeyID();

};

%brickgroup = new SimGroup("BrickGroup_" @ getNumKeyID())
{
client = 0;
bl_id = getNumKeyID();
name = $Pref::Player::NetName;
};

%brick = new fxDTSBrick()
{

client = $Mining::Host;
dataBlock = "brick4xCubeData";
position = "0 0 800";
rotation = "0 0 0 0";
colorID = 0;
scale = "1 1 1";
angleID = 0;
colorfxID = 0;
shapefxID = 0;
isPlanted = 1;
stackBL_ID = $Mining::Host.bl_id;

};

%brick.plant();
%brick.setTrusted(1);

$Mining::Host.brickgroup.add(%brick);

May help you out, took this from my Mining addon.
« Last Edit: June 30, 2013, 10:47:50 AM by TheBlackParrot »

Gee, you've been asking a lot of questions that you could have gotten answered by using the search feature, I guess I'll write you a quick guide on creating bricks, and please, if you spot and error in it, let me know.



First, you'll need to create a new object, the object type for bricks I believe is 'FxDTSBrick'

Quote
%brick = new FxDTSBrick();
{

Next, you'll need to specify the bricks datablock, for example, if I wanted to make this brick a 1 by 2 flat, I would use the datablock 'brick1x2FData'.

Quote
%brick = new FxDTSBrick();
{
        dataBlock = "brick1x2FData";

If you ever need to find the name of certain bricks datablock, plant that brick in your server and while looking at it, type /getID, it should display the ID of that brick and other various information, then you can type the following in your console to print the bricks datablocks name.

Quote
echo(XXXXX.dataBlock.getName()); // Replace the X's with the brick ID



Sweet! but you aren't finished yet, what if you need to create this brick at a different angle, well that's easy, just specify a rotation value and assign it the the 'rotation' field on your brick, since bricks can only be rotated in four directions, there are only four possible rotation values, one for north, one for south, one for east, and one for west.

Quote
North = 1 0 0 0
South = 0 0 1 180
East  = 0 0 1 90
West  = 0 0 -1 90

Quote
%brick = new FxDTSBrick();
{
        dataBlock = "brick1x2FData";
        rotation  = "1 0 0 0";



So, you've specified a datablock, and a rotation value, but if you were to plant this brick, where would it be planted, since you can't magically make your script plant a brick where your mind imagines it being, you need to do some math. Once you have a position value, assign it the the 'position' field and you should be good to go.

Quote
%brick = new FxDTSBrick();
{
        dataBlock = "brick1x2FData";
        rotation  = "1 0 0 0";
        position  = "0 0 0.1";



So now, I'm going to briefly go over how to add some color to your brick. When you specify a bricks color, the field is called 'colorID'. So you're probably wondering how you can find a colorID, there are multiple ways, but the fastest in my opinion is to reference your color set, when you spray paint a brick, it's going to be assigned a new colorID, so if you sprayed it with the very first color in your palette the colorID of that brick would be 0, think like a for loop for a second, if you as a for loop were told to iterate the color palette and you started off by indexing the first color as zero, what would the second colors index be?

Quote
%brick = new FxDTSBrick();
{
        dataBlock = "brick1x2FData";
        rotation  = "1 0 0 0";
        position  = "0 0 0.1";
        colorID = 0; // The first color in your set is most likely going to be red, it all depends on what color set you're using.

And very quickly, you can also for example, make your brick glow by specifying 'colorFxId', there are 7 possible effects you can specify, 0 being none, 1 being pearl, 2 being chrome, 3 being glow, 4 being blink, 5 being swirl and 6 being rainbow.

Quote
%brick = new FxDTSBrick();
{
        dataBlock = "brick1x2FData";
        rotation  = "1 0 0 0.1";
        position  = "0 0 0.1";
        colorID = 0; // The first color in your set is most likely going to be red, it all depends on what color set you're using.
        colorFxID = 3;

One last thing regarding adding color to your brick, there are two colors reserved in the specials row, these are to color your brick with a shape effect, have you ever used the undulo spray on a brick, well if you have, that bricks 'shapeFX' field was assigned the value of 1, there is also a shape effect that has been outlawed from your specials row, if you are every creating bricks for an ocean, or a pond, you can set this fields value to 2 and it should look wavy like water.

Quote
%brick = new FxDTSBrick();
{
        dataBlock = "brick1x2FData";
        rotation  = "1 0 0 0";
        position  = "0 0 0.1";
        colorID = 0; // The first color in your set is most likely going to be red, it all depends on what color set you're using.
        colorFxID = 3;
        shapeFxID = 0;



Gah, I need sleep, been up all day... and since parrot answered before me, I'm just going to finish that later in case anyone might need it. And like I said, if you see any false information in there, just let me know and I'll fix it as soon as I can :)
« Last Edit: June 30, 2013, 08:32:37 PM by Kadon »

Don't forget position, rotation, stackblid and client arguments

Gah, I need sleep, been up all day... and since parrot answered before me, I'm just going to finish that later in case anyone might need it. And like I said, if you see any false information in there, just let me know and I'll fix it as soon as I can :)
it's really small but

Code: [Select]
echo(XXXXX.dataBlock); //Replace the X's with the brick ID

you need to do the getName() method

it's really small but

you need to do the getName() method
you need to use getDatablock()

you need to use getDatablock()
yeah, normally it's a good idea to use the getX() methods.

i didn't include that because i decided that was too trivial

unless of course you're saying getDatablock in that way will always return the name instead of an id