Advertisement
Lion4ever

head_blocked.1.1

Aug 18th, 2015
516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.30 KB | None | 0 0
  1. --Floating Blocks by negamartin
  2. --You can use it for whatever you want, copy, modify, distribute it or use it as a base for your own structures
  3.  
  4. --Get what the main program is telling us to do
  5. local args={...};
  6.  
  7. --If it wants to know how much probability we have to be chosen when selecting the next structure
  8. if args[1]=="weight" then
  9.     return 1;   --We have a normal structure's probability to be chosen
  10.    
  11. --If it wants us to build the structure,
  12. elseif args[1]=="build" then
  13.     --Get the angle the last structure had
  14.     local lastAngle=args[2];
  15.    
  16.     --Get a random height difference for the block we are going to place in relation to the last block, from -2 to 1
  17.     local hdif;
  18.     local r=math.random();
  19.     if  r<0.22222 then  hdif=-1;
  20.     elseif  r<0.33333 then  hdif=-2;
  21.     else                    hdif=0;
  22.     end
  23.    
  24.     --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)
  25.     local dist;
  26.     if hdif==-1 then dist=4;
  27.     elseif hdif==-2 then dist=4.3;
  28.     elseif hdif==0 then dist=3.6;
  29.     end
  30.    
  31.     --Get the new angle, which is (+-)0.3PI from the previous angle (lastAngle)
  32.     local ang=lastAngle-math.pi*0.3+math.random()*math.pi*0.6;
  33.     local ang2=ang-math.pi*0.3+math.random()*math.pi*0.6
  34.     --Get the radius of our areaCheck sphere depending on the height difference
  35.     local sphere;
  36.     if hdif==-2 then sphere=7;
  37.     elseif hdif==-1 then sphere=6;
  38.     else sphere=5; end
  39.    
  40.     --Create our setblock parameters and place them in a table
  41.     local b={
  42.         math.floor(0.5+math.cos(ang)*dist),
  43.         0,
  44.         math.floor(0.5+math.sin(ang)*dist),
  45.         "minecraft:stone",
  46.     };
  47.     local c={
  48.         math.floor(b[1]+math.cos(ang2)*dist),
  49.         hdif,
  50.         math.floor(b[3]+math.sin(ang2)*dist),
  51.         "minecraft:stone",
  52.     };
  53.     --Return the StructureTable, with everything it needs to have
  54.     return {
  55.         blocks={b,{b[1],b[2]+3,b[3],b[4]},c},                               --The blocks table contains 1 element: the floating block
  56.         areaCheck={{b[1],b[2],b[3],sphere},{c[1],c[2],c[3],sphere}},    --The areaCheck table also only contains 1 element, our floating block area check.
  57.         exit={c[1],c[2],c[3]},                  --The exit of this structure is this same block
  58.         next=ang2,                              --Tell the next structure our angle was this
  59.         length=50,                              --This structure is 15% a total checkpoint-to-checkpoint parkour section in normal difficulty
  60.     };
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement