matthew117

Untitled

May 15th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. -- remove duplicate serums
  2.  
  3. local chest = peripheral.wrap("back")
  4.  
  5. while true do
  6.  
  7. local serumTable = {}
  8.  
  9. for i=1, chest.getInventorySize() do
  10.  
  11. local itemStack = chest.getStackInSlot(i)
  12. if itemStack then
  13. if serumTable[itemStack.name] ~= nil then -- there exists another serum of this type
  14. if itemStack.dmg < serumTable[itemStack.name] and chest.getStackInSlot(serumTable[itemStack.name]) then -- the one in the chest is higher quality
  15. if chest.getStackInSlot(serumTable[itemStack.name]).dmg == 16 then
  16. chest.pushItem("up", serumTable[itemStack.name], 1)
  17. end
  18. else
  19. if chest.getStackInSlot(i).dmg == 16 then
  20. chest.pushItem("up", i, 1)
  21. end
  22. end
  23. else -- serum hasn't been seen yet, so add to table
  24. serumTable[itemStack.name] = i
  25. end
  26. end
  27.  
  28. end
  29.  
  30. sleep(1)
  31. end
Advertisement
Add Comment
Please, Sign In to add comment