Advertisement
SryNotToxic

Untitled

Oct 6th, 2024
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. -- Initialize peripherals
  2. local meBridge = peripheral.wrap("left") -- Adjust based on your setup, e.g., 'left', 'right', etc.
  3. local monitor = peripheral.wrap("right") -- Adjust to your setup
  4.  
  5. -- Set the monitor's text scale (optional)
  6. monitor.setTextScale(0.5)
  7.  
  8. -- Function to print to the monitor
  9. local function printToMonitor(text, line)
  10. monitor.setCursorPos(1, line)
  11. monitor.clearLine()
  12. monitor.write(text)
  13. end
  14.  
  15. -- Function to list and display items in the AE2 network
  16. local function displayItems()
  17. monitor.clear()
  18.  
  19. -- Fetch items from the AE2 network
  20. local items = meBridge.listItems()
  21.  
  22. if not items then
  23. printToMonitor("No items in the network", 1)
  24. return
  25. end
  26.  
  27. -- Display items (limit to 4 lines to fit the 4x5 monitor)
  28. local line = 1
  29. for _, item in pairs(items) do
  30. local displayText = string.format("%s: %d", item.name:match(":(%w+)$") or item.name, item.count)
  31. printToMonitor(displayText, line)
  32. line = line + 1
  33. if line > 4 then break end -- Fit the 4x5 display
  34. end
  35. end
  36.  
  37. -- Main loop to refresh and display the items
  38. while true do
  39. displayItems()
  40. sleep(5) -- Refresh every 5 seconds
  41. end
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement