7 posts
Posted 13 April 2013 - 10:20 AM
I am wanting to print a string from a rednet server. It works if I dont put in mon.print and it prints on the computer but not the screen! Help ME!
mon = peripheral.wrap("top")
rednet.open("right")
while true do
event, id, text = os.pullEvent()
if event == "rednet_message" then
mon.print(id .. "> " ..text)
end
end
169 posts
Posted 13 April 2013 - 10:23 AM
mon = peripheral.wrap("top")
term.redirect(mon)
rednet.open("right")
while true do
id, text = rednet.receive()
print(id .. "> " .. text)
end
It's not enough to wrap the monitor, you also have to redirect the output to the monitor with term.redirect(). And you can use rednet.receive() to wait for a rednet message, instead of using os.pullEvent().
1522 posts
Location
The Netherlands
Posted 13 April 2013 - 10:28 AM
mon = peripheral.wrap("top")
term.redirect(mon)
rednet.open("right")
while true do
id, text = rednet.receive()
print(id .. "> " .. text)
end
It's not enough to wrap the monitor, you also have to redirect the output to the monitor with term.redirect(). And you can use rednet.receive() to wait for a rednet message, instead of using os.pullEvent().
To extend this, you can only use write on a monitor. You have to redirect it when you want to use print