Lee_Lenalee

Smart Hopper

Jan 24th, 2021 (edited)
773
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.79 KB | None | 0 0
  1. shell.openTab("shell")
  2.  
  3. function rotate180()
  4.     turtle.turnLeft()
  5.     turtle.turnLeft()
  6. end
  7.  
  8. function suckAndDrop(slot)
  9.     local MC_STACK_DEFAULT_SIZE = 64
  10.    
  11.     turtle.select(slot)
  12.     if (turtle.getItemDetail(slot) and turtle.getItemDetail(slot).count < MC_STACK_DEFAULT_SIZE) or (turtle.getItemDetail(slot) == nil) then
  13.         local itemsNeededToFillStack = MC_STACK_DEFAULT_SIZE - (turtle.getItemDetail(slot) and turtle.getItemDetail(slot).count or 0)
  14.         turtle.suck(itemsNeededToFillStack)
  15.     end
  16.     turtle.dropDown()
  17. end
  18.  
  19. while peripheral.find("NBT_Observer").read_state().facing ~= "south" do
  20.     turtle.turnLeft()
  21. end
  22.  
  23. while true do
  24.     local COAL_SLOT = 1
  25.     local IRON_SLOT = 2
  26.     local SEC_SLEEP = 1
  27.    
  28.     suckAndDrop(COAL_SLOT)
  29.     rotate180()
  30.     suckAndDrop(IRON_SLOT)
  31.     rotate180()
  32.     os.sleep(SEC_SLEEP)
  33. end
Add Comment
Please, Sign In to add comment