Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.93 KB | None | 0 0
  1. local sideTunnelDistance=2;
  2. local sideTunnelLength=5;
  3. local cobbleSlot = 1;
  4.  
  5. function digForward(number)
  6.     for i = 0,number,1
  7.     do
  8.         turtle.dig();
  9.         stepForward();
  10.         placeBlocksLeftRight();
  11.         turtle.digUp();
  12.         turtle.up();
  13.         placeBlocksLeftRight();
  14.         placeBlockUp();
  15.         turtle.down();
  16.     end
  17. end
  18.  
  19. function moveForward(stepNumber)
  20.     if(stepNumber==nil)then
  21.         stepForward();
  22.     else
  23.         for sn=0,stepNumber,1 do
  24.             stepForward();
  25.         end
  26.     end
  27. end
  28.  
  29. function stepForward()
  30.     if(turtle.getFuelLevel()<50)then
  31.         if(turtle.refuel())then
  32.             print("Successfully refuelled");
  33.         else
  34.             print("Refuelling failed... shutting off!");
  35.             error("Refuelling failed!");
  36.         end
  37.     end
  38.     turtle.forward();
  39. end
  40.  
  41. function stepUp()
  42.     if(turtle.getFuelLevel()<50)then
  43.         if(turtle.refuel())then
  44.             print("Successfully refuelled");
  45.         else
  46.             print("Refuelling failed... shutting off!");
  47.             error("Refuelling failed!");
  48.         end
  49.     end
  50.     turtle.up();
  51. end
  52.  
  53. function placeBlocksLeftRight()
  54.     turtle.turnLeft();
  55.     placeCobbleFront();
  56.     turtle.turnLeft();
  57.     turtle.turnLeft();
  58.     placeCobbleFront();
  59.     turtle.turnRight();
  60. end
  61.  
  62. function placeCobbleFront()
  63.     --TODO: Finish this method
  64.     --check wether the old slot still contains cobblestone
  65.     if((turtle.getItemDetail(cobbleSlot) ~= nil) and (turtle.getItemDetail(cobbleSlot).name=="minecraft:cobblestone"))then
  66.         turtle.place(cobbleSlot);
  67.     else
  68.         if(getcobbleSlot() == false)then
  69.         print("No Cobblestone left. this might become messy :("); --TODO: stop when there is no cobble left?
  70.         else
  71.             turtle.place(cobbleSlot);
  72.         end
  73.     end
  74. end
  75.  
  76. function placeBlockUp()
  77.     if(turtle.getItemDetail(cobbleSlot).name=="minecraft:cobblestone")then
  78.     turtle.placeUp(cobbleSlot);
  79. else
  80.     if(getcobbleSlot() == false)then
  81.     print("No Cobblestone left. this might become messy :("); --TODO: stop when there is no cobble left?
  82.     else
  83.         turtle.placeUp(cobbleSlot);
  84.     end
  85. end
  86. end
  87.  
  88. function endTunnel()
  89.     placeCobbleFront();
  90.     turtle.up();
  91.     placeCobbleFront();
  92.     turtle.down();
  93. end
  94.  
  95. function getcobbleSlot()
  96.     for i=1,9,1  do
  97.         if(turtle.getItemDetail(cobbleSlot).name=="minecraft:cobblestone")then
  98.             cobbleSlot = i;
  99.             return true;
  100.         end
  101.     end
  102.     return false;
  103. end
  104.  
  105.  
  106. --Here begins the actual Script
  107. for k=0,10,1
  108. do
  109.     digForward(sideTunnelDistance+1);
  110.     endTunnel()
  111.     turtle.turnLeft();
  112.     digForward(sideTunnelLength);
  113.     endTunnel()
  114.     turtle.turnLeft();
  115.     turtle.turnLeft();
  116.     moveForward(sideTunnelLength);
  117.     digForward(sideTunnelLength);
  118.     endTunnel()
  119.     turtle.turnLeft();
  120.     turtle.turnLeft();
  121.     moveForward(sideTunnelLength);
  122.     turtle.turnRight();
  123. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement