Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mon = peripheral.wrap("top")
- local wmod = peripheral.wrap("bottom")
- wmod.open(1)
- wmod.open(2)
- wmod.open(3)
- wmod.open(4)
- mon.clear()
- mon.setTextScale(0.8)
- mon.setCursorPos(1,1)
- function StartUp()
- while true do
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- local words = split(message,"|SPLIT|")
- term.redirect(mon)
- if words[1] == "ADDED" then
- term.setTextColour(colors.green)
- print("ADDED: "..words[3].. " ["..words[2].."]")
- else
- term.setTextColour(colors.red)
- print("REMOVED: "..words[3].. " ["..words[2].."]")
- end
- term.restore()
- end
- end
- function split( str, regex )
- local t = { }
- local fpat = "(.-)"..regex
- local last_end = 1
- local s, e, cap = str:find(fpat, 1)
- while s do
- if s ~= 1 or cap ~= "" then
- table.insert(t,cap)
- end
- last_end = e+1
- s, e, cap = str:find(fpat, last_end)
- end
- if last_end <= #str then
- cap = str:sub(last_end)
- table.insert(t, cap)
- end
- return t
- end
- StartUp()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement