Advertisement
sanderronde

move_eggs.lua

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