Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local login = {}
- term.write("channel name: ")
- login.host = read()
- term.write("channel password: ")
- login.pass = read("*")
- term.write("channel nickname: ")
- login.user = read()
- rednet.broadcast("from:"..os.computerLabel()..", join:"..login.host)
- i = 0
- while true do
- e,s,m = os.pullEvent("rednet_message")
- print("e: "..e.." s: "..s.." m: "..m)
- i = 1
- for k,v in string.gmatch(m,"(%w+):(%w+)") do
- if k == "from" or k == "host" then
- c[i] = {k,v}
- i = i+1
- end
- end
- if c[1][1] == "from" then
- if c[1][2] == login.host and c[2][1]..":"..c[2][2] == "host:ok" then
- rednet.send(s,"from:"..os.computerLabel()..", pass:"..login.pass)
- o = 0
- repeat
- e,s,m = os.pullEvent("rednet_message")
- print("e: "..e.." s: "..s.." m: "..m)
- i = 1
- for k,v in string.gmatch(m,"(%w+):(%w+)") do
- if k == "from" or k == "access" then
- c[i] = {k,v}
- i = i+1
- end
- if i == 3 then o = 1 end
- end
- until o == 1
- if c[1][1] == "from" and c[1][2] == login.host and c[2][1] == "access" then
- if c[2][2] == "granted" then
- login.access = true
- elseif c[2][2] == "denied" then
- login.access = false
- end
- if login.access then
- else
- end
- print(login.access)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement