Advertisement
Zantag

Untitled

Dec 24th, 2014
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. chest = peripheral.wrap("right")
  2. chestDir = "north"
  3. dumpItemsColor = 0xEEE --all red
  4. for k,v in pairs(chest) do
  5. print(k)
  6. end
  7.  
  8. function setColor(i)
  9. if chest == nil then
  10. print(" :( ")
  11. end
  12. chest.setFrequency(i)
  13. end
  14.  
  15. function getAllItems()
  16. for fromSlot = 1, chest.getInventorySize() do
  17. chest.pushItem(chestDir,fromSlot,64)
  18. end
  19. end
  20.  
  21. function resetTurtle()
  22. getAllItems()
  23. setColor(dumpItemsColor)
  24. for fromSlot = 1, 16 do
  25. chest.pullItem(chestDir,fromSlot,64)
  26. end
  27. setColor(0)
  28. end
  29.  
  30. function init()
  31. resetTurtle()
  32. end
  33.  
  34. function waitForRecipeAndHandle()
  35.  
  36. while true do
  37. setColor(0)
  38. items = chest.getAllStacks()
  39. os.sleep(1)
  40. if #items > 0 then
  41. chestNum = 1
  42. getAllItems()
  43. for fromSlot = 1,16 do
  44. ic = turtle.getItemCount(fromSlot)
  45. if ic > 0 then
  46. print(items[fromSlot].display_name)
  47. end
  48. for i = 1, ic do
  49. setColor(chestNum)
  50. chest.pullItem(chestDir, fromSlot, 1)
  51. chestNum = chestNum + 1
  52. os.sleep(0.05)
  53. end
  54. end
  55. end
  56. os.sleep(0.5)
  57. end
  58. end
  59.  
  60. init()
  61. waitForRecipeAndHandle()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement