Advertisement
JackGrey

Send to monitor

Oct 16th, 2024
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. local modem = peripheral.wrap("left") -- Wrap the modem connected to the left side
  2. modem.open(1) -- Open channel 1 for communication
  3.  
  4. -- Your logic for generating the list of missing items
  5. local allItems = {"Apples", "Bananas", "Oranges", "Grapes"} -- Example full list
  6. local availableItems = {"Apples", "Grapes"} -- Example of what's already available
  7.  
  8. -- Function to determine missing items
  9. local function getMissingItems(all, available)
  10. local missing = {}
  11. for _, item in ipairs(all) do
  12. local found = false
  13. for _, availableItem in ipairs(available) do
  14. if item == availableItem then
  15. found = true
  16. break
  17. end
  18. end
  19. if not found then
  20. table.insert(missing, item)
  21. end
  22. end
  23. return missing
  24. end
  25.  
  26. -- Generate the list of missing items
  27. local missingItems = getMissingItems(allItems, availableItems)
  28.  
  29. -- Send the list wirelessly to the monitor on channel 1
  30. modem.transmit(1, 1, missingItems)
  31.  
  32. print("Missing items sent wirelessly!")
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement