19 posts
Location
Argentina
Posted 26 August 2013 - 02:32 AM
Hello! I did a thread with my problem before. I want see the same program in the four monitors. Please read this
http://www.computercraft.info/forums2/index.php?/topic/14831-multiple-monitors/ . I don't know how can I do this, so please tell me the edited code. I'm newbie in LUA and CC. Thanks!
7508 posts
Location
Australia
Posted 26 August 2013 - 02:44 AM
Just as Last1Here and Kingdaro showed in that thread, we can use tables and a loop to get this to work. Something like the following example…
local targets = {
"back:red";
"back:green";
"back:blue";
"back:cyan";
--# etc, etc, etc
}
local function doMonitor( device )
--# redirect to the target
term.redirect( device )
--# your code goes here, making sure to ONLY use term. calls instead off direct calls on the monitor
--# avoid infinite loops, this really should just be the render code for the monitors
--# restore the terminal
term.restore()
end
--# if you want to do anything like text scale do it here
for index,name in ipairs(targets) do
peripheral.call(name, "setTextScale", 0.5)
end
--# infinite loops goes here
while true do
--# process user input and such here
--# loop through the targets to draw to them
for index,name in ipairs(targets) do
--# wrap the target and supply it to the doMonitor function
doMonitor( peripheral.wrap(name) )
end
end