Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- WirelessReceiver.lua
- -- Version 1.0
- -- Author: AshGrey
- -- Date: 2024-10-16
- -- This script listens for transmitted missing item data from the AE2Warehouse script
- -- and displays the information on the wireless pocket computer.
- -------------------------------------------------------------------------------
- -- INITIALIZATION
- -------------------------------------------------------------------------------
- -- Initialize Ender Modem
- local modem = peripheral.wrap("back") -- Wrap the Ender Modem on the left side
- if not modem then error("Ender Modem not found.") end
- print("Ender Modem initialized.")
- -- Set the modem to listen on the specified channel
- local channel = 1
- modem.open(channel)
- print("Listening for missing items on channel:", channel)
- -------------------------------------------------------------------------------
- -- MAIN LOOP
- -------------------------------------------------------------------------------
- while true do
- -- Wait for a message on the specified channel
- local senderID, receivedChannel, message = os.pullEvent("modem_message")
- -- Ensure the message is on the right channel
- if receivedChannel == channel then
- print("Received missing items data:", message)
- -- Display the missing items
- print("Missing Items:")
- for itemData in message:gmatch("[^;]+") do
- local itemName, count = itemData:match("([^:]+):([^:]+)")
- print(itemName .. ": " .. count)
- end
- end
- -- Short sleep to prevent CPU overuse
- sleep(0.5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement