Guest User

Untitled

a guest
Oct 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. local args = {...}
  2.  
  3. function accept()
  4. rs.setBundledOutput("back", colors.yellow)
  5. end
  6.  
  7. function reject()
  8. rs.setBundledOutput("back", colors.red)
  9. end
  10.  
  11. function load()
  12. rs.setBundledOutput("back", colors.blue)
  13. end
  14.  
  15. function sortChestContents()
  16. return sensors.getReading("top", "Sensor")[0]
  17. end
  18.  
  19. function loadNext()
  20. local contents = nil
  21.  
  22. load()
  23.  
  24. repeat
  25. contents = sortChestContents()
  26. os.sleep(1)
  27. until contents ~= nil
  28. end
  29.  
  30. function select(name)
  31. while true do
  32. loadNext()
  33.  
  34. local contents = sortChestContents()
  35. print("item detected: " .. contents)
  36.  
  37. if string.find(contents, name) then
  38. -- sort chest contains sought item
  39. accept()
  40. return
  41. else
  42. -- sort chest doesn't contain sought item
  43. reject()
  44. end
  45. end
  46. end
  47.  
  48. select(args[1])
Add Comment
Please, Sign In to add comment