Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- WirelessMonitor.lua
- -- Version 1.1
- -- Author: Modified by AshGrey
- -- Date: 2024-10-16
- -- This script runs on the wireless computer with a monitor to display missing items from the AE2 Warehouse.
- -------------------------------------------------------------------------------
- -- INITIALIZATION
- -------------------------------------------------------------------------------
- -- Initialize the wireless monitor
- local monitor = peripheral.wrap("right") -- Adjust if necessary
- if not monitor then error("Monitor not found.") end
- monitor.setTextScale(0.5)
- monitor.clear()
- print("Monitor initialized.")
- -- Initialize the Ender Modem
- local modem = peripheral.wrap("left") -- Adjust if necessary
- if not modem then error("Ender Modem not found.") end
- print("Ender Modem initialized.")
- -------------------------------------------------------------------------------
- -- FUNCTIONS
- -------------------------------------------------------------------------------
- -- Display the missing items received from the main computer
- function displayMissingItems(missingItems)
- monitor.clear()
- monitor.setCursorPos(1, 1)
- monitor.write("Missing Items:")
- local line = 2
- for item in string.gmatch(missingItems, "([^;]+)") do
- local name, count = item:match("([^:]+):([^:]+)")
- if name and count then
- monitor.setCursorPos(1, line)
- monitor.write(name .. ": " .. count)
- line = line + 1
- end
- end
- end
- -------------------------------------------------------------------------------
- -- MAIN LOOP
- -------------------------------------------------------------------------------
- print("Starting Wireless Monitor...")
- modem.open(1) -- Open a channel (choose any number)
- while true do
- -- Listen for messages from the main computer
- local event, side, channel, replyChannel, message = os.pullEvent("modem_message")
- if channel == 1 then -- Ensure it matches the opened channel
- displayMissingItems(message) -- Display the missing items on the monitor
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement