This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
RandomnessThatsFunny's profile picture

Monitor Help!

Started by RandomnessThatsFunny, 13 April 2013 - 08:20 AM
RandomnessThatsFunny #1
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
SadKingBilly #2
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().
Engineer #3
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