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

How do I use terminal.redirect and print in terminal at same time

Started by Meit, 23 July 2016 - 05:54 PM
Meit #1
Posted 23 July 2016 - 07:54 PM
Hi guys, Code first then I tell what I am trying ok?

if peripheral.getType("top") == "monitor" then
	    monside = "top"
    end
    if peripheral.getType("bottom") == "monitor" then
	    monside = "bottom"
    end
    if peripheral.getType("right") == "monitor" then
	    monside = "right"
    end
    if peripheral.getType("left") == "monitor" then
	    monside = "left"
    end
    if monside == "none" then
    else
	    monitorget = peripheral.wrap( monside )
	    monitorget.setTextScale(2.8)
    end
    if monside == "none" then
    else
	    term.write(text)
	    printCentered(h / 2, text)
	    write(text)
	    --[[term.redirect(peripheral.wrap(monside))
	    if not peripheral.getType("top") == "nill" then
		    term.redirect(peripheral.wrap("top"))
	    end
	    if not peripheral.getType("bottom") == "nill" then
		    term.redirect(peripheral.wrap("bottom"))
	    end
	    if not peripheral.getType("right") == "nill" then
		    term.redirect(peripheral.wrap("right"))
	    end
	    if not peripheral.getType("left") == "nill" then
		    term.redirect(peripheral.wrap("left"))
	    end
	    if not peripheral.getType("front") == "nill" then
		    term.redirect(peripheral.wrap("front"))
	    end
	    if not peripheral.getType("back") == "nill" then
		    term.redirect(peripheral.wrap("back"))
	    end--]]
	    write(text)
	    term.write(text)
	    printCentered(h / 2, text)
    end
    printCentered(h / 2, text)
Ok now as you see in the code I am redirecting to all the connected peripherals and the code is working but I want to make the text appear in the terminal too and send too.. But it dosent go to terminal even if I try anything, Help me please I will appreciate it :)/>
The Crazy Phoenix #2
Posted 23 July 2016 - 10:56 PM
If you want to write to two displays simultaneously, you will need to create a table containing each function inside the term API implemented to display to both terminals. You can then term.redirect to that table and both displays should be used.

Or if you have control over all the code then just wrap the display and store the return value instead of redirecting.


local monitors = {peripheral.find("monitor")}  -- peripheral.find returns all peripherals of the wanted type. These are already wrapped.
for monitor in ipairs(monitors) do  -- Iterate over the monitors
    monitor.write("Hello World!")  -- Display to each monitor
end
Lupus590 #3
Posted 23 July 2016 - 11:22 PM
http://www.computercraft.info/forums2/index.php?/topic/14831-multiple-monitors/