Guest User

Untitled

a guest
Oct 30th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. local login = {}
  2.  
  3. term.write("channel name: ")
  4. login.host = read()
  5. term.write("channel password: ")
  6. login.pass = read("*")
  7. term.write("channel nickname: ")
  8. login.user = read()
  9. rednet.broadcast("from:"..os.computerLabel()..", join:"..login.host)
  10. i = 0
  11.  
  12. while true do
  13. e,s,m = os.pullEvent("rednet_message")
  14. print("e: "..e.." s: "..s.." m: "..m)
  15. i = 1
  16. for k,v in string.gmatch(m,"(%w+):(%w+)") do
  17. if k == "from" or k == "host" then
  18. c[i] = {k,v}
  19. i = i+1
  20. end
  21. end
  22. if c[1][1] == "from" then
  23. if c[1][2] == login.host and c[2][1]..":"..c[2][2] == "host:ok" then
  24. rednet.send(s,"from:"..os.computerLabel()..", pass:"..login.pass)
  25. o = 0
  26. repeat
  27. e,s,m = os.pullEvent("rednet_message")
  28. print("e: "..e.." s: "..s.." m: "..m)
  29. i = 1
  30. for k,v in string.gmatch(m,"(%w+):(%w+)") do
  31. if k == "from" or k == "access" then
  32. c[i] = {k,v}
  33. i = i+1
  34. end
  35. if i == 3 then o = 1 end
  36. end
  37. until o == 1
  38. if c[1][1] == "from" and c[1][2] == login.host and c[2][1] == "access" then
  39. if c[2][2] == "granted" then
  40. login.access = true
  41. elseif c[2][2] == "denied" then
  42. login.access = false
  43. end
  44. if login.access then
  45. else
  46. end
  47. print(login.access)
  48. end
  49. end
  50. end
  51. end
Advertisement
Add Comment
Please, Sign In to add comment