| Blockland Forums > Modification Help |
| How to place bricks using scripting? |
| (1/2) > >> |
| I-have-not:
I was thinking of using some script to plant bricks to auto build. I wanna know if this'll work, but I need to know how to place bricks first. |
| Brian Smithers:
%brick = new fxDTSBrick() { datablock = datablockgoeshere; position = "positionhere"; angle = "anglehere"; colorID = colorIDHere; }; MissionGroup.add(%brick); %brick.setTrusted(1); %brick.plant(); That should work I think. I probably missed a few functions/arguments. |
| Ipquarx:
--- Code: ---function createBrick(%pos, %Datablock, %AngleID, %ColourID, %ColourFXId) { %host = findClientByBL_ID(getNumKeyID()); %hostID = getNumKeyID(); %posx = getWord(%pos, 0); %posy = getWord(%pos, 1); %posz = getWord(%pos, 2); %brick = new fxDTSBrick() { client = %host; datablock = %Datablock; position = %posx SPC %posy SPC %posz; rotation = "0 0 0 0"; colorID = %ColourID; scale = "1 1 1"; angleID = %AngleID; colorfxID = %ColourFXId; shapefxID = "0"; isPlanted = 1; stackBL_ID = %hostID; }; %brick.setTrusted(1); %brick.plant(); %host.brickgroup.add(%brick); } --- End code --- Use that to create a brick that has the host's ownership. I'm assuming that's what you want, as you're probably using it for your own purposes. BTW: Brians code will not work. |
| Slicksilver:
--- Quote from: Ipquarx on February 10, 2012, 09:38:29 PM ---BTW: Brians code will not work. --- End quote --- It should. This is ripped straight out of my networked terrain generator: --- Code: ---function ChunkTCP::makeBrickAtHeight(%this, %pos, %db, %color) { if(getWord(%pos,2) == 0) return; %brick = new fxDTSBrick() { position = vectorAdd(%pos,"0 0 1.2"); dataBlock = %db; colorID = %color; isBasePlate = 1; isPlanted = 1; }; %brick.setTrusted(1); BrickGroup_10.add(%brick); %brick.plant(); } --- End code --- Granted mine leaves out some goodies like angleid because they're unneeded when building cubes, but it should work nonetheless. |
| Port:
You make also find this example useful which allows you to bypass specific planting errors, and let other errors be fatal (taken from block_types.cs in my System_Tarpex): --- Code: ---function blockType::createBrick( %this, %position, %angleId, %noFloat ) { %obj = new fxDTSBrick() { position = %position; rotation = "1 0 0" SPC 90 * %angleId; dataBlock = %this.dataBlock; angleId = %angleId; colorId = %this.colorId; blockType = %this; }; %obj.setTrusted( true ); getTPXBrickGroup().add( %obj ); // You will probably want to change this line. %err = %obj.plant(); if ( %err ) { if ( !%noFloat && %err == 2 ) // You might want to change this line. { %obj.isPlanted = true; %obj.plant(); return %obj; } else { %obj.delete(); return %err; } } return %obj; } --- End code --- This will place a block which is allowed to be floating, but not overlapping, buried, etc. |
| Navigation |
| Message Index |
| Next page |