PETREKILLAH

Miner

Dec 4th, 2018 (edited)
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. function GetCoal()
  2. local count = 16
  3. repeat
  4. local currentSlot = turtle.getSelectedSlot()
  5. local data = turtle.getItemDetail(currentSlot)
  6. if data.name == "minecraft:coal" then
  7. return true
  8. else
  9. turtle.select((currentSlot%16)+1)
  10. count = count - 1
  11. end
  12.  
  13. until(count == 0)
  14. print("Can't find coal")
  15. return false
  16. end
  17.  
  18. function RefuelCoal()
  19. if turtle.getFuelLevel() == 0 then
  20. local result = GetCoal()
  21. if result then
  22. print("Coal Found! Refueling")
  23. turtle.refuel(1)
  24. else
  25. print("No Coal Found!")
  26. end
  27. return result
  28. else
  29. return true
  30. end
  31. end
  32.  
  33. amount = arg[1] or 50
  34. print("Mining for " .. amount .. " blocks")
  35. for i=1,amount,1 do
  36. result = RefuelCoal()
  37. if result then
  38. turtle.dig()
  39. turtle.digUp()
  40. turtle.forward()
  41. else
  42. error("OUT OF FUEL")
  43. end
  44. end
Add Comment
Please, Sign In to add comment