Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Listener for rednet
- -- initiating variables
- messages = {}
- line = 1
- -- monitor and rednet setup
- rednet.open("back")
- monitor = peripheral.wrap("top")
- monitor.clear()
- monitor.setTextScale(1)
- monitor.setCursorPos(1, 1)
- -- defining functions
- function displayMsg(screen, msg, id)
- print("displaying messages")
- for i = 1, 12 do
- monitor.setCursorPos(1, i)
- monitor.setTextColor(id)
- monitor.write(msg[i])
- print("message displayed: ".. msg[i])
- end
- end
- function scroll(msg)
- print("scrolled")
- for i = 1, 12 do
- msg[i] = msg[i+1]
- end
- return msg
- end
- -- main program loop
- while true do
- event, id, message = os.pullEvent()
- if event == "rednet_message" then
- print("message received")
- newMsg = tostring(id.." > "..message)
- messages[line] = newMsg
- print("message stored")
- if line < 12 then
- line = line + 1
- print("adding additional line")
- elseif line == 12 then
- messages = scroll(messages)
- else
- print("line scrolling error")
- end
- displayMsg(monitor, messages, id)
- print("text displayed")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement