Stary2001

Untitled

Jan 5th, 2013
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. rednet.open("right")
  2.  
  3. local args={...}
  4. local id = tonumber(args[1]) or error("No ID!")
  5. while true do
  6. io.write("remote>")
  7. local line = io.read()
  8. local cmd,args = string.gmatch(line,"^(.-) (.+)$")()
  9.  
  10. if not string.find(line," ") then
  11. cmd = line
  12. args = ""
  13. end
  14.  
  15. if not cmd then
  16. print("Enter a command!")
  17. else
  18. rednet.send(id,"cmd:exe:"..cmd..":"..args)
  19.  
  20. while true do
  21. local e,maybeSid,msg = os.pullEvent()
  22.  
  23. if e == "rednet_message" then
  24. local sid = maybeSid
  25. if sid==id then
  26. if msg=="\1done" then
  27. break
  28. elseif msg == "\1read" then
  29. rednet.send(id,io.read())
  30. elseif msg:sub(1,13) == "\1setCursorPos" then
  31. local p = string.find(msg,",")
  32. local a = msg:sub(14,p-1)
  33. local b = msg:sub(p+1)
  34. term.setCursorPos(tonumber(a),tonumber(b))
  35. elseif msg == "\1clear" then
  36. term.clear()
  37. elseif msg == "\1clearLine" then
  38. term.clearLine()
  39. elseif msg == "\1scroll" then
  40. term.scroll()
  41. else
  42. print(msg)
  43. end
  44. end
  45. elseif e == "key" then
  46. rednet.send(id, "cmd:key:"..maybeSid)
  47. elseif e == "char" then
  48. rednet.send(id,"cmd:char:"..maybeSid)
  49. end
  50. end
  51. end
  52. end
  53.  
  54. rednet.close("right")
Advertisement
Add Comment
Please, Sign In to add comment