Advertisement
Guest User

tunnelV2

a guest
Jun 23rd, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.79 KB | None | 0 0
  1. function reOrganiseInv()
  2.   for i=1,16 do
  3.     if turtle.getItemCount(i)==0 then
  4.       turtle.select(i+1)
  5. function reFuel()
  6.   if turtle.getFuelLevel() <= 200 then
  7.     turtle.select(1)
  8.     turtle.refuel(1)
  9.   end
  10. end
  11. function remainingSlots()
  12.   emptySlots =0
  13.   for i=1,16 do
  14.     if turtle.getItemCount(i)==0 then
  15.       emptySlots=emptySlots+1
  16.     end
  17.   end
  18.   return emptySlots
  19. end
  20. function backTrack()
  21.   turtle.turnLeft()
  22.   turtle.turnLeft()
  23.   count =0
  24.  
  25.   repeat
  26.     count = count+1
  27.     local success, data = turtle.forward()
  28.     if success then
  29.     end
  30.     if count%5==0 then
  31.       turtle.turnLeft()
  32.       turtle.select(2)
  33.       turtle.place()
  34.       turtle.turnRight()
  35.       turtle.select(1)
  36.     end
  37.   until not success  
  38. end
  39. function clearSpace()
  40.   turtle.turnLeft()
  41.   turtle.turnLeft()
  42.   dropCount=0
  43.   for i=1,16 do
  44.     local data = turtle.getItemDetail(i)
  45.     if data then
  46.       if data.name =="minecraft:cobblestone" then
  47.         turtle.select(i)
  48.         turtle.drop()
  49.         dropCount=dropCount+1
  50.       end
  51.     end
  52.   end
  53.   if dropCount ==0 then
  54.     backTrack()
  55.     exit()    
  56.   end
  57.   turtle.turnLeft()
  58.   turtle.turnLeft()
  59. end            
  60. function tunnelV2(x)
  61.   for i = 1,x do
  62.     turtle.dig()
  63.     turtle.forward()
  64.     turtle.digUp()
  65.     turtle.turnLeft()
  66.     turtle.dig()
  67.     turtle.up()
  68.     turtle.dig()
  69.     turtle.turnRight()
  70.     turtle.turnRight()
  71.     turtle.dig()
  72.     turtle.down()
  73.     turtle.dig()
  74.     turtle.turnLeft()
  75.     reFuel()
  76.     if remainingSlots()== 0 then
  77.       clearSpace()
  78.     end
  79.    end
  80.   backTrack()
  81. end
  82. local args={...}
  83. x=args[1]
  84. y=args[2]
  85. for i=1,y do
  86.   turtle.dig()
  87.   turtle.forward()
  88.   turtle.digUp()
  89.   if i%5==0 then
  90.     print("i is : ",i)
  91.     turtle.turnLeft()
  92.     tunnelV2(x)
  93.     turtle.turnLeft()
  94.   end
  95. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement