Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ladder_swerve_jump.1
- -- For use with this: http://www.computercraft.info/forums2/index.php?/topic/23785-virtual-parkour/
- --Get what the main program is telling us to do
- local args={...};
- local trans = {{["x+"]=5, ["x-"]=4, ["z+"]=3, ["z-"]=2},
- {["x+"]=3, ["x-"]=2, ["z+"]=4, ["z-"]=5},
- {["x+"]=2, ["x-"]=3, ["z+"]=5, ["z-"]=4},
- {["x+"]=4, ["x-"]=5, ["z+"]=2, ["z-"]=3}}
- --If it wants to know how much probability we have to be chosen when selecting the next structure
- if args[1]=="weight" then
- return 0.3;
- --If it wants us to build the structure,
- 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=4.9;
- elseif hdif==-1 then dist=5.9;
- elseif hdif==-2 then dist=6.5;
- elseif hdif==0 then dist=5.7;
- 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 b1={
- math.floor(0.5+math.cos(ang)*dist),
- hdif,
- math.floor(0.5+math.sin(ang)*dist),
- "minecraft:stone",
- };
- local b1lad1={
- b1[1]-1;
- b1[2],
- b1[3],
- "minecraft:ladder",
- };
- local ladderOffset=numberToDir(dirToNumber(final().next)+2);
- b1lad1[5]=trans[1][ladderOffset];
- local b1lad2={
- b1[1],
- b1[2],
- b1[3],
- "minecraft:ladder",
- };
- if b1[3]>0 then --To the right, ladder on left
- b1lad2[3]=b1lad2[3]-1;
- b1lad2[5]=trans[2][ladderOffset];
- else --To the left, ladder on right
- b1lad2[3]=b1lad2[3]+1;
- b1lad2[5]=trans[3][ladderOffset];
- end
- local b2 = {
- b1[1],
- b1[2] + 1,
- b1[3],
- "minecraft:stone",
- };
- local b2lad1={
- b2[1]+1;
- b2[2],
- b2[3],
- "minecraft:ladder",
- };
- local ladderOffset=numberToDir(dirToNumber(final().next)-2);
- b2lad1[5]=trans[4][ladderOffset];
- local b2lad2={
- b2[1],
- b2[2],
- b2[3],
- "minecraft:ladder",
- };
- if b1[3]<0 then --To the right, ladder on left
- b2lad2[3]=b2lad2[3]-1;
- b2lad2[5]=trans[2][ladderOffset];
- else --To the left, ladder on right
- b2lad2[3]=b2lad2[3]+1;
- b2lad2[5]=trans[3][ladderOffset];
- end
- local b3 = {
- b2[1],
- b2[2] + 1,
- b2[3],
- "minecraft:stone",
- };
- --Return the StructureTable, with everything it needs to have
- return {
- blocks={b1,b1lad1,b1lad2,b2,b2lad1,b2lad2,b3}, --The blocks table contains 1 element: the floating block
- areaCheck={{b2[1],b2[2],b2[3],sphere}}, --The areaCheck table also only contains 1 element, our floating block area check.
- exit={b3[1],b3[2],b3[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
Advertisement