Advertisement
DabDaddy6223

tbt_mine_torch.lua

Mar 5th, 2023
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.53 KB | None | 0 0
  1. local MaxTorchDistance = 14
  2.  
  3. function getIndexOf(item)
  4.     for i = 1, 16 do
  5.         local item = turtle.getItemDetail(i, false)
  6.         if item["name"] == item then
  7.             return i
  8.         end
  9.     end
  10.  
  11.     return -1
  12. end
  13.  
  14. function refuel()
  15.     if turtle.getFuelLevel() == 0 then
  16.         for i = 1, 16 do
  17.             turtle.select(i)
  18.             if turtle.refuel(0) then
  19.                 return true
  20.             end
  21.         end
  22.  
  23.         print("No fuel found!")
  24.         return false
  25.     else
  26.         return true
  27.     end
  28. end
  29.  
  30. function main()
  31.     local torchDistance = 0
  32.     local indexOfTorches = getIndexOf("minecraft:torch")
  33.  
  34.     if indexOfTorches == -1 then
  35.         print("No torches found!")
  36.         return
  37.     end
  38.  
  39.     if indexOfTorches ~= 0 then
  40.         turtle.select(indexOfTorches)
  41.         turtle.transferTo(0)
  42.     end
  43.  
  44.     while true do
  45.         if refuel() then
  46.             turtle.dig()
  47.             turtle.forward()
  48.             turtle.digDown()
  49.  
  50.             torchDistance = torchDistance + 1
  51.             if torchDistance == MaxTorchDistance then
  52.                 turtle.placeDown()
  53.                 torchDistance = 0
  54.             end
  55.  
  56.             turtle.dig("left")
  57.             turtle.dig("right")
  58.             turtle.down()
  59.             turtle.dig("left")
  60.             turtle.dig("right")
  61.             turtle.up()
  62.             turtle.up()
  63.             turtle.dig("left")
  64.             turtle.dig("right")
  65.             turtle.down()
  66.         else
  67.             break
  68.         end
  69.     end
  70. end
  71.  
  72. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement