Advertisement
Guest User

tunnel

a guest
Nov 23rd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.76 KB | None | 0 0
  1. function outoffuel()
  2.     if turtle.getFuelLevel()==0 then
  3.         t=turtle.getSelectedSlot()
  4.  i=1
  5.         while i<17  do
  6.             if check_slot(i) then
  7.     rednet.broadcast("Slot ".. i.." has no coal")
  8.     else
  9.             turtle.select(i)
  10.                 turtle.refuel(4)
  11.     break
  12.             end
  13.             i=i+1
  14.         end
  15.     turtle.select(t)
  16. end
  17. end
  18. function improvedDig()
  19.  while  turtle.inspect() do
  20.      turtle.dig()
  21.      end
  22. end
  23. function check_slot(value)
  24.  a=turtle.getItemDetail(value)
  25.     if turtle.getItemCount(value)==0 or a.name~="minecraft:coal" or a.name~="minecraft:coal_block" then
  26.         return true
  27.  else
  28.         return false
  29.     end
  30. end
  31. function push()
  32.     improvedDig()
  33.     turtle.forward()
  34. end
  35. function forward_mine(value)
  36.     for i=0,value,1 do
  37.     outoffuel()
  38.     push()
  39.     end
  40. end
  41. function placeRight()
  42. turtle.turnRight()
  43. a=turtle.inspect()
  44. if not a then
  45.     selector("minecraft:cobblestone")
  46.     turtle.place()
  47. end
  48. turtle.turnLeft()
  49. end
  50. function selector(string)
  51. i=1
  52.  
  53.  while i<17 do
  54.     a,b= turtle.select(i)
  55.     if a==true and b.name==string then
  56.         return true
  57.     else
  58.     i=i+1
  59.     end
  60.  end
  61. rednet.broadcast("Out of :" .. string)
  62. exit()
  63. end
  64. function placeLeft()
  65. turtle.turnLeft()
  66. a=turtle.inspect()
  67. if not a then
  68.     selector("minecraft:cobblestone")
  69.     turtle.place()
  70. end
  71. turtle.turnRight()
  72. end
  73. function dig_tunnel(depth)
  74. forward_mine(1)
  75. for i=0,depth,1 do
  76.     for k=0,1,1 do
  77.         placeRight()
  78.         turtle.turnLeft()
  79.         forward_mine(2)
  80.         turtle.place()
  81.         turtle.turnRight()
  82.         turtle.digUp()
  83.         turtle.up()
  84.         turtle.placeLeft()
  85.         turtle.right()
  86.         forward_mine(2)
  87.         turtle.place()
  88.         turtle.turnLeft()
  89.         turtle.digUp()
  90.         turtle.up()
  91.     end
  92. end
  93. end
  94. io.write("Pass depth")
  95. depth=io.read()
  96. rednet.broadcast("R2 is diggin tunnel 4x3x"..depth)
  97. dig_tunnel(depth)
  98. rednet.broadcast("Digging succesfull")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement