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

[Lua] [Help] Sync Terminals!

Started by timyo24, 12 August 2012 - 05:49 PM
timyo24 #1
Posted 12 August 2012 - 07:49 PM
Ok, so i can write a code to sync a monitor and a terminal together, buuuuutt im wondering if there is a code i can use over rednet to sync to terminals together so i can type on one computer and be coding another. Thanks! :P/>/>
Pharap #2
Posted 13 August 2012 - 02:58 AM
First you need a program that prints whatever it receives as a rednet message: (assume the modem is on the top side of the computer)


rednet.open("top")
do while true
e, id, msg = os.pullEvent()
if e = "rednet_message" then
if msg == "TerminateConsolePlease" then
break
else
print(msg)
end
end
end

have that run on a computer next to a monitor by running it through the monitor program (Assume it's called screenwrite, and the monitor is on the computer's left side)

monitor left screenwrite.

And now, for the computer further away, have it run this: (assuming modem is on top again)


rednet.open("top")
do while true
input = read()
rednet.broadcast(input)
if input == "TerminateConsolePlease" then
break
end
end

That's probably the most basic way of doing it, but I'll leave you to explore the wiki and improve it as your programming skills get better. After all, no sense throwing you in the deep end.
Lyqyd #3
Posted 13 August 2012 - 07:03 AM
If you want it to work correctly, you'll want to use terminal redirection with a custom redirection table to send and receive the screen information to and from the remote computer. Any other method is basically going to limit what you can do.

As it happens, the LyqydNet API does have terminal redirection over rednet already, so you may be able to adapt that code to your uses. It's in the connection API; the two functions at the bottom of the file implement the two ends of it.