Guest User

Untitled

a guest
Jun 2nd, 2017
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. UserID = 1
  2. pass = " " --10 caractere
  3. local Authenticate = {" "," 1 1"}
  4. local User = {" ","debug"}
  5. local function openRednet()
  6. local listOfSides = rs.getSides()
  7. for i = 1,6 do
  8. if peripheral.isPresent(listOfSides[i]) and peripheral.getType(listOfSides[i]) == "modem" then
  9. rednet.open(listOfSides[i])
  10. return listOfSides[i]
  11. end
  12. end
  13. end
  14. modemOn = openRednet()
  15. if not modemOn then
  16. print("No WIFI Modem\nPress any key to return to exit")
  17. os.pullEvent("key")
  18. return
  19. end
  20. function os.pullEventRaw(...)
  21. local e1,e2,e3,e4,e5 = coroutine.yield(...)
  22. if e1 == "rednet_message" and e2 == UserID then
  23. local a = string.sub(e3,1,3)
  24. if a == "key" then
  25. return "key",tonumber(string.sub(e3,4,string.len(e3)))
  26. elseif a == "cha" then
  27. return "char",string.sub(e3,4,4)
  28. end
  29. end
  30. return e1,e2,e3,e4,e5
  31. end
  32. remote = {}
  33. function remote.write(s)
  34. rednet.send(UserID,"WRT"..s)
  35. end
  36. function remote.clear()
  37. rednet.send(UserID,"CLR")
  38. end
  39. function remote.clearLine()
  40. rednet.send(UserID,"CLL")
  41. end
  42. function remote.setCursorBlink(s)
  43. rednet.send(UserID,"SCB"..tostring(s))
  44. end
  45. function remote.setCursorPos(X,Y)
  46. rednet.send(UserID,"SCP"..textutils.serialize({X,Y}))
  47. end
  48. function remote.getSize()
  49. rednet.send(UserID,"GSZ")
  50. while true do
  51. local w1,w2,w3 = os.pullEvent("rednet_message")
  52. if string.sub(w3,1,3) == "SIZ" then
  53. local a = textutils.unserialize(string.sub(w3,4,string.len(w3)))
  54. return a[1],a[2]
  55. end
  56. end
  57. end
  58. function remote.getCursorPos()
  59. rednet.send(userID,"GCP")
  60. while true do
  61. local w1,w2,w3 = os.pullEvent("rednet_message")
  62. if string.sub(w3,1,3) == "pos" then
  63. local a = textutils.unserialize(string.sub(w3,4,string.len(w3)))
  64. return a[1],a[2]
  65. end
  66. end
  67. end
  68. function remote.scroll(nLines)
  69. rednet.send(UserID,"SCR"..tostring(nLines))
  70. end
  71.  
  72. term.clear()
  73. term.setCursorPos(1,1)
  74. print("Remote Terminal Started")
  75. while true do
  76. local q1,q2,q3,q4,q5 = os.pullEvent()
  77. print(tostring(q1).." "..tostring(q2))
  78. if q1 == "rednet_message" then
  79. local test = string.sub(q3,1,10)
  80. local DAT = textutils.unserialize(string.sub(q3,11,string.len(q3)))
  81. if test == pass and Authenticate[1] == DAT then
  82. term.clear()
  83. term.setCursorPos(1,1)
  84. print("open Connection")
  85. rednet.send(q2,"Request Accepted")
  86. sleep(5)
  87. UserID = q2
  88. term.clear()
  89. term.setCursorPos(1,1)
  90. print("User "..User[1].." online")
  91. break
  92. elseif test == Authenticate[2] then
  93. term.clear()
  94. term.setCursorPos(1,1)
  95. print("debug du system")
  96. sleep(10)
  97. os.reboot()
  98. end
  99. end
  100. end
Add Comment
Please, Sign In to add comment