Advertisement
MudkipTheEpic

Screen Share Client

Feb 8th, 2013
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.19 KB | None | 0 0
  1. local derpy={}
  2. local function open()
  3. for k,v in pairs(rs.getSides()) do
  4. if peripheral.getType(v) == "modem" then rednet.open(v) return true end
  5. end
  6. return false
  7. end
  8. if not open() then error("Needs modem") end
  9. term.clear()
  10. while true do
  11. term.setCursorPos(1,1)
  12. term.clearLine()
  13. print("What Computer ID would you like to connect to?")
  14. write("ID> ")
  15. id = tonumber(read())
  16. derpy.id=id
  17. if id then print("ID is "..id) break end
  18. print("Invalid ID.")
  19. sleep(3)
  20. term.setCursorPos(2,1)
  21. term.clearLine()
  22. term.setCursorPos(3,1)
  23. term.clearLine()
  24. end
  25. print("What password does ID #"..id.." have?")
  26. write("Password: ")
  27. local pass = read()
  28. rednet.send(tonumber(id), pass)
  29. repeat
  30. local i,msg = rednet.receive(3)
  31. until i == id or i == nil
  32. print("")
  33. write("Trying to connect in 3..")
  34. sleep(1)
  35. write("2..")
  36. sleep(1)
  37. write("1..")
  38. sleep(1)
  39. term.clear()
  40. term.setCursorPos(1,1)
  41. local function listen()
  42. while true do
  43. e,s = rednet.receive()
  44. if e == tonumber(derpy.id) then
  45. if s == "done" then
  46. term.clear()
  47. term.setCursorPos(1,1)
  48. print("End of broadcast!")
  49. return
  50. end
  51. local ok, err = pcall(loadstring(s))
  52. if not ok then
  53. print("Unexpected error: "..err.."!")
  54. return
  55. end
  56. end
  57. end
  58. end
  59. listen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement