Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("right")
- local args={...}
- local id = tonumber(args[1]) or error("No ID!")
- while true do
- io.write("remote>")
- local line = io.read()
- local cmd,args = string.gmatch(line,"^(.-) (.+)$")()
- if not string.find(line," ") then
- cmd = line
- args = ""
- end
- if not cmd then
- print("Enter a command!")
- else
- rednet.send(id,"cmd:exe:"..cmd..":"..args)
- while true do
- local e,maybeSid,msg = os.pullEvent()
- if e == "rednet_message" then
- local sid = maybeSid
- if sid==id then
- if msg=="\1done" then
- break
- elseif msg == "\1read" then
- rednet.send(id,io.read())
- elseif msg:sub(1,13) == "\1setCursorPos" then
- local p = string.find(msg,",")
- local a = msg:sub(14,p-1)
- local b = msg:sub(p+1)
- term.setCursorPos(tonumber(a),tonumber(b))
- elseif msg == "\1clear" then
- term.clear()
- elseif msg == "\1clearLine" then
- term.clearLine()
- elseif msg == "\1scroll" then
- term.scroll()
- else
- print(msg)
- end
- end
- elseif e == "key" then
- rednet.send(id, "cmd:key:"..maybeSid)
- elseif e == "char" then
- rednet.send(id,"cmd:char:"..maybeSid)
- end
- end
- end
- end
- rednet.close("right")
Advertisement
Add Comment
Please, Sign In to add comment