Posted 10 June 2013 - 09:30 AM
I want to send a small message via network cable to a nearby monitor, but I'm stumped on the way to send messages via the cable. When I initially tried I got errrors that the peripheral didn't support those commands (term.clear() & term.setCursorPos()) so I worked out that I was trying to send those commands just to the wired modem and not down the wire.
I've had another look at the wiki and realised that I should be using p.callRemote(peripheral name, peripheral method) but I cannot work out how to use it in the above code. Do I have to send a callRemote() for each of the commands, or is there some way to wrap it so I can do it once?
edit: derp derp derp… :/
Also I need an easy method to return the monitor name so that when I initialise the program I can store that name in the ini. When I called the correct API function I got a table string which is less than helpful.
Calling the p.getMethodsRemote() instead of p.getNamesRemote() will of course return a table instead of a string… :/
function monOutput(msg)
term.redirect(peripheral.wrap(monSide))
term.clear()
term.setCursorPos(1,1)
term.print(pName)
term.print(textutils.formatTime(os.time(),boolean))
term.print(msg)
term.restore()
end
function output(msg)
if monitor == 1 then
monOutput(msg)
else
term.clear()
term.setCursorPos(1,1)
print(textutils.formatTime(os.time(), boolean))
print(msg)
end
end
I've had another look at the wiki and realised that I should be using p.callRemote(peripheral name, peripheral method) but I cannot work out how to use it in the above code. Do I have to send a callRemote() for each of the commands, or is there some way to wrap it so I can do it once?
edit: derp derp derp… :/
Calling the p.getMethodsRemote() instead of p.getNamesRemote() will of course return a table instead of a string… :/
Edited on 10 June 2013 - 10:27 AM