Advertisement
sanderronde

eggbot.lua

Jan 3rd, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.92 KB | None | 0 0
  1. local function store_egg()
  2.     turtle.turnLeft()
  3.     turtle.turnLeft()
  4.     turtle.select(2)
  5.     turtle.drop(1)
  6.     turtle.turnLeft()
  7.     turtle.turnLeft()
  8. end
  9.  
  10. local function craft_eggs()
  11.     turtle.select(2)
  12.     turtle.suck(1)
  13.     if turtle.getItemCount() == 0 then
  14.         return
  15.     end
  16.  
  17.     turtle.craft(1)
  18.    
  19.     --Crafted item is in slot 2
  20.     store_egg()
  21. end
  22.  
  23. local function is_facing_egg_chest()
  24.     local success, data = turtle.inspect()
  25.     if not success then
  26.         -- Air in front of it
  27.         return false
  28.     end
  29.     if data.name == "minecraft:chest" then
  30.         return true
  31.     end
  32.     return false
  33. end
  34.  
  35. local function orient()
  36.     while not is_facing_egg_chest() do
  37.         turtle.turnLeft()
  38.     end
  39. end
  40.  
  41. local function clean_inventory()
  42.     turtle.select(2)
  43.     if turtle.getItemCount() > 0 then
  44.         turtle.turnRight()
  45.         turtle.drop(1)
  46.         turtle.turnLeft()
  47.     end
  48. end
  49.  
  50. local function main()
  51.     orient()
  52.     clean_inventory()
  53.     while true do
  54.         craft_eggs()   
  55.     end
  56. end
  57.  
  58. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement