Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Get what the main program is telling us to do
- local args={...};
- --If it wants to know how much probability we have to be chosen when selecting the next structure
- if args[1]=="place_marker" then
- local s=args[2];
- s.placeMarker=true;
- return true;
- elseif args[1]=="check_exit" then
- local s=args[2];
- return commands.getBlockInfo(s.blocks[2][1],s.blocks[2][2],s.blocks[2][3]).name~="minecraft:web" and
- commands.testfor(s.playerData.incompleteSelector.."x="..s.exit[1]..",y="..(s.exit[2]+1)..",z="..s.exit[3]..",r=1]");
- elseif args[1]=="death" then
- local s=args[2];
- if s.bowGiven then
- if s.complete then
- s.blocks[4][5]=0;
- for i=2,13 do
- if i~=3 then commands.async.setblock(unpack(s.blocks[i])); end
- end
- else
- commands.async.clear(s.playerData.selector.." minecraft:bow");
- commands.async.clear(s.playerData.selector.." minecraft:arrow");
- s.blocks[4][5]=0;
- commands.async.setblock(unpack(s.blocks[4]));
- commands.async.setblock(s.blocks[3][1],s.blocks[3][2],s.blocks[3][3],"minecraft:air 0 replace");
- end
- s.complete=false;
- s.bowGiven=false;
- end
- elseif args[1]=="build" then
- local b={};
- local ac={};
- --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.7;
- 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
- b[1]={
- math.floor(0.5+math.cos(ang)*dist),
- hdif,
- math.floor(0.5+math.sin(ang)*dist),
- "minecraft:stone",
- };
- ac[#ac+1]={b[1][1],b[1][2],b[1][3],sphere};
- b[2]={
- math.floor(b[1][1]+0.5+math.cos(ang)*4),
- hdif,
- math.floor(b[1][3]+0.5+math.sin(ang)*4),
- "minecraft:web",
- };
- ac[#ac+1]={b[2][1],b[2][2],b[2][3],5};
- local targetSide=math.random(0,1);
- if targetSide==0 then targetSide=-1; end
- local distance=((checkpointStride()-100)*0.2+30)*targetSide;
- b[4]={
- b[1][1],
- hdif+2,
- b[1][3]+distance,
- "minecraft:wool",
- 0,
- };
- b[3]={
- b[4][1],
- b[4][2],
- b[4][3]-targetSide,
- "minecraft:wooden_button",
- disableAutobuild=true,
- autoMeta=true,
- };
- if targetSide==1 then b[3][5]="z-";
- elseif targetSide==-1 then b[3][5]="z+";
- else error("Invalid targetSide "..tostring(targetSide)); end
- b[5]={
- b[4][1],
- b[4][2]+1,
- b[4][3],
- "minecraft:wool",
- };
- b[6]={
- b[4][1]+1,
- b[4][2],
- b[4][3],
- "minecraft:wool",
- };
- b[7]={
- b[4][1]-1,
- b[4][2],
- b[4][3],
- "minecraft:wool",
- };
- b[8]={
- b[4][1],
- b[4][2]-1,
- b[4][3],
- "minecraft:wool",
- };
- b[9]={
- b[4][1]-1,
- b[4][2]+1,
- b[4][3],
- "minecraft:wool",
- };
- b[10]={
- b[4][1]+1,
- b[4][2]+1,
- b[4][3],
- "minecraft:wool",
- };
- b[11]={
- b[4][1]-1,
- b[4][2]-1,
- b[4][3],
- "minecraft:wool",
- };
- b[12]={
- b[4][1]+1,
- b[4][2]-1,
- b[4][3],
- "minecraft:wool",
- };
- b[13]={
- b[4][1],
- b[4][2],
- b[4][3]+targetSide,
- "minecraft:command_block",
- 0,
- "replace",
- --"{Command:\"setblock "..tb13[1].." "..tb13[2].." "..tb13[3].." minecraft:stone\"}",
- };
- function doStuff(struct)
- local pd=struct.playerData;
- if not struct.bowGiven then
- struct.bowGiven=true;
- commands.async.clear(pd.selector.." minecraft:bow");
- commands.async.clear(pd.selector.." minecraft:arrow");
- commands.async.give(pd.selector.." minecraft:bow");
- commands.async.give(pd.selector.." minecraft:arrow 4");
- struct.blocks[4][5]=14;
- commands.async.setblock(unpack(struct.blocks[4]));
- commands.setblock(unpack(struct.blocks[3]));
- commands.async.tellraw(pd.selector,"{text:\"Shoot the red target. You'll only be given more arrows if you suicide.\",color:gold}");
- end
- if commands.getBlockInfo(unpack(struct.blocks[13])).name=="minecraft:stone" then
- for i=3,13 do
- commands.async.setblock(struct.blocks[i][1],struct.blocks[i][2],struct.blocks[i][3],"minecraft:air");
- end
- commands.async.clear(pd.selector.." minecraft:bow");
- commands.async.clear(pd.selector.." minecraft:arrow");
- local tb2=struct.blocks[2];
- if struct.placeMarker then commands.async.setblock(tb2[1],tb2[2],tb2[3],"minecraft:obsidian");
- else commands.async.setblock(tb2[1],tb2[2],tb2[3],"minecraft:stone"); end
- struct.complete=true;
- end
- end
- ac[#ac+1]={b[1][1],b[1][2]+1,b[1][3],1,doStuff};
- --Return the StructureTable, with everything it needs to have
- return {
- blocks=b, --The blocks table contains 1 element: the floating block
- areaCheck=ac, --The areaCheck table also only contains 1 element, our floating block area check.
- exit={b[2][1],b[2][2],b[2][3]}, --The exit of this structure is this same block
- next=ang, --Tell the next structure our angle was this
- length=20, --This structure is 15% a total checkpoint-to-checkpoint parkour section in normal difficulty
- };
- elseif args[1]=="post_transform" then
- local tb13=args[2].blocks[13];
- tb13[7]="{Command:\"setblock "..tb13[1].." "..tb13[2].." "..tb13[3].." minecraft:stone\"}";
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement