Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --RedNetLog by MisterMeister32
- local function open()
- p = peripheral.getNames()
- local modem = nil
- local for i = 1, #p do --seaching for modems
- if peripheral.getType(p[i]) == "modem" then
- modem = p[i]
- end
- end
- if modem == nil then --opening, when found
- return false
- else
- rednet.open(modem)
- return true
- end
- end
- local function log() --actual logger
- while true do
- local id, msg, prot = rednet.receive()
- msg = textutils.serialise(msg)
- print(id.."("..prot.."):"..msg)
- end
- end
- local function stop() --stop on keypress
- while true do
- a = os.pullEvent("key")
- if a == "key" then
- break
- end
- end
- end
- if open() then
- print("Press any key to exit.")
- parallel.waitForAny(log, stop)
- else
- print("No modem found.")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement