Advertisement
GeoffAlexander

hMine

Jan 3rd, 2021 (edited)
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.14 KB | None | 0 0
  1. -- pastbin.com/Edbsn4ga
  2.  
  3. local tArgs = { ... }
  4. local length = 10
  5. local torch_slot = 16
  6. local fuel_slot = 15
  7.  
  8. if #tArgs ~= 1 then
  9.     print('Usage: hMine <length>')
  10.     return
  11. else
  12.     length = tonumber(tArgs[1])
  13. end
  14.  
  15. function hMine()
  16.     textutils.slowPrint(string.format('Mining forward %d blocks...', length))
  17.     for i = 1, length, 1 do
  18.         turtle.forward()
  19.         detectDig()
  20.         if i % 10 == 0 then
  21.             placeTorch()
  22.         end
  23.     end
  24.     placeTorch()
  25.     print(string.format('Finished mining %d blocks!', length))
  26. end
  27.  
  28. function detectDig()
  29.     while(turtle.detect() == true) do
  30.         turtle.dig()
  31.     end
  32.     while(turtle.detectUp() == true) do
  33.         turtle.digUp()
  34.     end
  35.     turtle.digDown()
  36. end
  37.  
  38. function placeTorch()
  39.     local slotData = turtle.getItemDetail(torch_slot)
  40.     if  slotData.name == "minecraft:torch" then
  41.         turtle.select(torch_slot)
  42.         turtle.turnLeft()
  43.         turtle.turnLeft()
  44.         turtle.place()
  45.         turtle.turnLeft()
  46.         turtle.turnLeft()
  47.     else
  48.         return
  49.     end
  50. end
  51.  
  52. hMine()
  53.  
  54. if (tArgs == "down" or tArgs == "Down") then
  55.    
  56. end
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement