Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Floating Blocks by negamartin
- --Modified to Booby Trap by Lion4ever
- --You can use it for whatever you want, copy, modify, distribute it or use it as a base for your own structures
- --Get what the main program is telling us to do
- local args={...};
- function waitForExplosion(x,y,z)
- while commands.getBlockInfo(x,y,z).name == "minecraft:air" and
- commands.getBlockInfo(x,y-1,z).name == "minecraft:stone" do
- sleep(1)
- end
- end
- --If it wants to know how much probability we have to be chosen when selecting the next structure
- if args[1]=="weight" then
- return 1; --We have a normal structure's probability to be chosen
- --If it wants us to build the structure,
- elseif args[1]=="death" then
- local s = args[2]
- waitForExplosion(unpack(s.blocks[3]))
- for i,b in ipairs(s.blocks) do
- commands.async.setblock(unpack(b))
- end
- elseif args[1]=="remove_structure" then
- local s = args[2]
- waitForExplosion(unpack(s.blocks[3]))
- return false -- so that the remaining blocks are still removed
- elseif args[1]=="place_marker" then
- local fence=args[2].blocks[1];
- fence[4]="minecraft:obsidian";
- commands.async.setblock(unpack(fence));
- return true;
- elseif args[1]=="build" then
- --Get the angle the last structure had
- local lastAngle=args[2];
- --Get a random height difference for the block we are going to place in relation to the last block, from -2 to 1
- local hdif;
- local r=math.random();
- if r>0.66666 then hdif=1;
- elseif r<0.22222 then hdif=-1;
- elseif r<0.33333 then hdif=-2;
- else hdif=0;
- end
- --Get the distance between the last block and the one we are gonna place, depending on the height difference (if the block is lower you can jump farther)
- local dist;
- if hdif==1 then dist=3.2;
- elseif hdif==-1 then dist=5;
- elseif hdif==-2 then dist=5.3;
- elseif hdif==0 then dist=4.6;
- end
- --Get the new angle, which is (+-)0.3PI from the previous angle (lastAngle)
- local ang=lastAngle-math.pi*0.3+math.random()*math.pi*0.6;
- --Get the radius of our areaCheck sphere depending on the height difference
- local sphere;
- if hdif==-2 then sphere=7;
- elseif hdif==-1 then sphere=6;
- else sphere=5; end
- --Create our setblock parameters and place them in a table
- local b={
- math.floor(0.5+math.cos(ang)*dist),
- hdif,
- math.floor(0.5+math.sin(ang)*dist),
- "minecraft:stone",
- };
- local bAll = {
- b,
- {b[1],b[2]+1,b[3],"minecraft:wooden_pressure_plate"},
- {b[1],b[2]-1,b[3],"minecraft:tnt"},
- {b[1],b[2]-2,b[3],b[4]},
- }
- for c=-1,1 do
- for d=-1,1 do
- if c ~= 0 or d ~= 0 then
- for e=-2,0 do
- table.insert(bAll,{b[1]+c,b[2]+e,b[3]+d,"minecraft:web"})
- end
- end
- end
- end
- --Return the StructureTable, with everything it needs to have
- return {
- blocks= bAll, --The blocks table contains 1 element: the floating block
- areaCheck={{b[1],b[2],b[3],sphere}}, --The areaCheck table also only contains 1 element, our floating block area check.
- exit={b[1],b[2],b[3]}, --The exit of this structure is this same block
- next=ang, --Tell the next structure our angle was this
- length=15, --This structure is 15% a total checkpoint-to-checkpoint parkour section in normal difficulty
- };
- end
Advertisement
Add Comment
Please, Sign In to add comment