5 posts
Posted 14 October 2014 - 02:36 AM
Is there any way to display on a monitor what you are doing on the computer? How would you?
3057 posts
Location
United States of America
Posted 14 October 2014 - 03:09 AM
term.redirect can change the output to the monitor
There are several apis that simultaneously display output on the terminal and a monitor, I believe there's one called sync.
5 posts
Posted 14 October 2014 - 03:24 AM
thanks so much!
5 posts
Posted 14 October 2014 - 03:54 AM
Well, actually that didn't seem to work, the closest i got was
local nativeTerm = term.native or term
local function invoke(sMethod, …)
nativeTerm[sMethod](…)
for k,sSide in pairs(redstone.getSides()) do
if peripheral.isPresent(sSide) and peripheral.getType(sSide) == "monitor" then
peripheral.call(sSide, sMethod, …)
end
end
end
term.write = function(text) invoke("write", text) end
term.scroll = function(n) invoke("scroll", n) end
term.setCursorPos = function(x, y) invoke("setCursorPos", x, y) end
term.setCursorBlink = function(:o/>/> invoke("setCursorBlink", :o/>/> end
term.clear = function() invoke("clear") end
term.clearLine = function() invoke("clearLine") end
nativeTerm.clear()
nativeTerm.setCursorPos(1, 1)
print(os.version())
by coryf88
but i don't know a lot about monitor commands, and i would like it to work on the top of the monitor, and supposedly the computer is supposed to be on the right? It also didn't quite run? i know i have to do something to the code, particularity the (…) after the sMethod in the lines? but I'm not sure what i have to put, could you explain this code and then tell me what i should do to get it to work?
(sorry lots of questions i know im a pain XD)
Edited on 14 October 2014 - 01:59 AM
3057 posts
Location
United States of America
Posted 14 October 2014 - 02:16 PM
I'm not sure what exactly your code is trying to do, but I assume you are trying to write simultaneously to monitors and the terminal.
Also, where did you get it has to be on the right? It can be on any side specified. peripheral.getNames() may interest you as well, since it can find monitors connected by network cables and wired modems.
Also, please, please use
and
tags.
74 posts
Posted 16 October 2014 - 03:55 AM
I'm not sure exactly what you're doing, but term.redirect() shows the computer on the monitor instead of in the shell. Example on how to do this:
mon = peripheral.wrap("top") --Can be left, right, bottom, top, back, or front. This is where monitor touches computer.
term.redirect(mon)
If what you want is something to print to the monitor AND the computer but not have them mirrored, you'd need to write your own function. Here's an example using print.
mon = peripheral.wrap("top") --Again, any side that was specified in previous example
red,blue,green,yellow,orange = "nobreaky"
if term.isColor() then
red = colors.red
blue = colors.blue
green = colors.green
yellow = colors.yellow
orange = colors.orange
end
function printAll(text, color)
if mon.isColor() then
mon.setTextColor(color)
end
mon.write(text.."\n")
if term.isColor() then
term.setTextColor(color)
end
print(text)
end
That code is a little bit more complicated than needed to prevent errors (using colors on a non-color computer)
Example how to use:
printAll("Text here!", blue) --'Blue' can be replaced with any of the colors I specified
Hope this helps!
3057 posts
Location
United States of America
Posted 16 October 2014 - 07:40 PM
Here's a quick, screwed up "sync" of the terminal and monitor:
local mon = peripheral.wrap( "side" )
for k, v in pairs( term ) do
term[ k ] = function( ... )
if mon[ k ] then
mon[ k ]( ... )
end
return v( ... )
end
end
Edited on 16 October 2014 - 05:41 PM