| Blockland Forums > Modification Help |
| function to spawn bricks? |
| (1/2) > >> |
| Waru:
blockland modding documentation is so spotty that i cant reliably find anything on it. Is there a function somewhere that'll spawn blocks in a certain location or something? |
| Dannu:
This is something that's lying in my pastebin. Important things to note are as follow: %color is an ID (integer), to get it manually, count on the paint menu starting on the top left, moving down and then going to the right, it would look smth like this: 036147258 So color ID for green would be 1. EDIT: Corrected colorID to start from 0 %client field in that example is going to represent the host, since getNumKeyID() returns the host's BL_ID. stackBL_ID in that example is %client.bl_id, but in retrospect, you probably want to use whatever you used for findClientByBL_ID. For host, this would then be --- Code: ---stackBL_ID = getNumKeyID(); --- End code --- This is in case the server is dedicated and the host isn't in the server, or the player you want to own the bricks isn't on the server -> the %client wouldn't exist. --- Code: ---position = VectorAdd(%x/2 SPC %y/2 SPC "50", $Temple::Position); ... $Temple::Map::chunk[%x, %y] = %brick; --- End code --- These are snippets that are specific to the project I was working on. The position is a string of three numbers (x y z coordinates) separated by spaces (i.e. 12 5 3) and the second part can be deleted alltogether. --- Code: ---BrickGroup_17003.add(%brick); --- End code --- This is mentioned in the paste as well, but BrickGroup_### is a simset for all of a client's bricks. The ### is the BL_ID of the client. |
| Shift Kitty:
--- Quote from: Dannu on October 26, 2017, 03:46:47 AM ---%color is an ID (integer), to get it manually, count on the paint menu starting on the top left, moving down and then going to the right, it would look smth like this: 147258369 So color ID for green would be 2. --- End quote --- Nooooooo. It starts from 0. |
| Dannu:
stuff my bad |
| Tendon:
--- Code: ---function nothereisntafunctionlikethat() { %brick = new fxdtsbrick() { datablock = "brick1x1Data"; position = "0.25 0.25 0.3"; rotation = "0 0 1 90"; isplanted = 1; }; %brick.setColor(10); brickgroup_31546.add(%brick); %brick.setTrusted(1); %err = %brick.plant(); if(%err!=0||%err!=2) { %brick.schedule(1,"delete"); } } --- End code --- %brick will be the object id of the newly created brick. you can replace brick1x1Data with the name of the datablock of whatever brick you're trying to create position is the center of the brick and will snap to the grid automatically. rotation is an axis angle formula [x y z][angle] in this case we rotate around the z axis, and we pick an angle divisible by 90, negatives are accepted I think? isplanted defines whether its a ghost brick or not. Like some variables, this should only do it's job at the initial creation of the brick. Changing isPlanted after the brick is created may not have the desired effect. afaik brick color has to be set after the brick is created, but i may be wrong add the brick to a brickgroup so it will be autodeleted on server shutdown, and so it interacts with the wrench properly if we want to plant the brick, we can either do a trust check or cut through that bullstuff and just set it as trusted. bricks will generate an error number when planted, 0 means OK, 2 means its floating, I forget the rest. aside from "too far", the rest of the errors mean the brick probably wont work right, so we just delete the brick if it didn't plant correctly. |
| Navigation |
| Message Index |
| Next page |