Advertisement
Guest User

pokehole3.0

a guest
Apr 23rd, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.09 KB | None | 0 0
  1. --pokeHole by Hypno
  2.  
  3. --***IMPORTANT READ THIS***
  4. --Fuel in slot 1 (coal/charcoal works great!)
  5. --Torches in slot 2
  6. --Ladders in slot 3 (no ladders needed if depth set to 0 or 1)
  7.  
  8. --set depth to how far below you want the turtle to start the pokeHole mine
  9. --set length to how long you want the mine.  Remember to stay within loaded chunks or have world anchors!
  10. --***IMPORTANT READ THIS***
  11.  
  12. local depth = 0
  13. local length = 100
  14. --                 pokehole length
  15. local fuelNeeded = ((length/3)*20) + (length*2) + (depth*2)
  16. local function checkFuel()
  17.     while (turtle.getFuelLevel() < fuelNeeded) do
  18.       turtle.select(1)
  19.       if (turtle.getItemCount(1) == 0) then
  20.         print("Not enough fuel.")
  21.         return false
  22.       end
  23.       turtle.refuel(1)
  24.     end
  25.     return true
  26. end
  27.  
  28. local function forwardYo()
  29.     while not turtle.forward() do
  30.         turtle.dig()
  31.     end
  32. end
  33.  
  34. local function checkTorches()
  35.     if (length / 10 > turtle.getItemCount(2)) then
  36.       print("Not enough torchs.")
  37.       return false
  38.     end
  39.     return true
  40. end
  41. local function checkLadders()
  42.     if (turtle.getItemCount(3) < depth) then
  43.       print("Not enough ladders.")
  44.       return false
  45.     end
  46.     return true
  47. end
  48. local function placeTorch()
  49.     turtle.select(2)
  50.     turtle.placeDown()
  51. end
  52. local function dig()
  53.     while (turtle.detect()) do
  54.         turtle.dig()
  55.         sleep(0.5)
  56.     end
  57. end
  58. local function digPokeHoles()
  59.     local i = 0
  60.     turtle.turnRight()
  61.     for i=0, 4 do
  62.         dig()
  63.         forwardYo()
  64.     end
  65.     turtle.turnLeft()
  66.     turtle.turnLeft()
  67.     for i=0, 4 do
  68.         forwardYo()
  69.     end
  70.     for i=0, 4 do
  71.         dig()
  72.         forwardYo)
  73.     end
  74.     turtle.turnRight()
  75.     turtle.turnRight()
  76.     for i=0, 4 do
  77.         forwardYo()
  78.     end
  79.     turtle.turnLeft()
  80. end
  81. local function digToDepth()
  82.     local ladder = false
  83.     if (depth > 1) then
  84.         ladder = true
  85.     end
  86.     if (ladder) then
  87.         turtle.turnRight()
  88.         turtle.turnRight()
  89.     end
  90.     local i = 0
  91.     while (i < depth) do
  92.         turtle.digDown()
  93.         turtle.down()
  94.         if (ladder) then
  95.             turtle.dig()
  96.             turtle.select(3)
  97.             turtle.place()
  98.         end
  99.         i = i + 1
  100.     end
  101.     turtle.digDown()
  102.     if (ladder) then
  103.         turtle.down()
  104.         turtle.dig()
  105.         turtle.select(3)
  106.         turtle.place()
  107.         turtle.up()
  108.         turtle.turnRight()
  109.         turtle.turnRight()
  110.     end
  111.     placeTorch()
  112.     digPokeHoles()
  113. end
  114. local function digTunnel()
  115.     local i = 0
  116.     local j = 0
  117.     local k = 0
  118.     while (i < length) do
  119.         dig()
  120.         forwardYo()
  121.         turtle.digDown()
  122.         j = j + 1
  123.         if (j == 10) then
  124.             placeTorch()
  125.             j = 0
  126.         end
  127.         k = k + 1
  128.         if (k % 4 == 0) then
  129.             digPokeHoles()
  130.             k = 0
  131.         end
  132.         i = i + 1
  133.     end
  134. end
  135. local function turnAround()
  136.     turtle.turnRight()
  137.     turtle.turnRight()
  138. end
  139. local function moveToTunnelStart()
  140.     local i = 0
  141.     for i=1,length do
  142.       forwardYo()
  143.     end
  144. end
  145. local function moveToStartDepth()
  146.     local i = 0
  147.     for i=1,depth do
  148.       turtle.up()
  149.     end
  150. end
  151. local function placeSafetyBlock()
  152.     turtle.select(4)
  153.     turtle.placeDown()
  154.     print("Complete.")
  155. end
  156.  
  157. --If not enough fuel, torches or ladders don't do anything.
  158. if checkFuel() and checkTorches() and checkLadders() then
  159.     digToDepth()
  160.     digTunnel()
  161.     placeTorch()
  162.     turnAround()
  163.     moveToTunnelStart()
  164.     turnAround()
  165.     moveToStartDepth()
  166.     placeSafetyBlock()
  167. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement