sanderronde

cobblestonebot.lua

Jan 10th, 2019
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.78 KB | None | 0 0
  1. local function is_facing_name(str)
  2.     local success, data = turtle.inspect()
  3.     if not success then
  4.         return false
  5.     end
  6.     if data.name == str then
  7.         return true
  8.     end
  9.     return false
  10. end
  11.  
  12. local function mine()
  13.     while not is_facing_name("minecraft:cobblestone") do
  14.         sleep(1)
  15.     end
  16.     turtle.dig()
  17. end
  18.  
  19. local function clear_inventory()
  20.     for s = 1, 16 do
  21.         turtle.select(s)
  22.         if turtle.getItemCount() < 64 then
  23.             return
  24.         end
  25.     end
  26.  
  27.     turtle.turnRight()
  28.     for s = 1, 16 do
  29.         turtle.select(s)
  30.         if not turtle.drop(64) then
  31.             print("Dumping chest is full")
  32.             while not turtle.drop(64) do
  33.                 sleep(5)
  34.             end
  35.         end
  36.     end
  37.     turtle.turnLeft()
  38. end
  39.  
  40. local function start()
  41.     while true do
  42.         clear_inventory()
  43.         mine() 
  44.     end
  45. end
  46.  
  47. local function init()
  48.     start()
  49. end
  50.  
  51. init()
Add Comment
Please, Sign In to add comment