Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local login = {}
- local c = {}
- local loop = true
- local function msg(m)
- return string.gsub(m,"%$(%w+)",login)
- end
- term.write("channel name: ")
- login.host = read()
- term.write("channel password: ")
- login.pass = read("*")
- term.write("channel nickname: ")
- login.user = read()
- rednet.broadcast(msg("from:"..os.computerLabel()..", join:$host"))
- i = 0
- while true do
- while loop do
- e,s,m = os.pullEvent("rednet_message")
- print("s: "..s.." m: "..m)
- for i,j,k,l in string.gmatch(m,"(%w+):(%w+), (%w+):(%w+)") do
- if i == "from" and k == "host" then
- c[1] = {i,j}
- c[2] = {k,l}
- loop = false
- end
- 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,msg("from:"..os.computerLabel()..", pass:$pass"))
- loop = true
- while loop do
- e,s,m = os.pullEvent("rednet_message")
- print("e: "..e.." s: "..s.." m: "..m)
- for i,j,k,l in string.gmatch(m,"(%w+):(%w+), (%w+):(%w+)") do
- if i == "from" and k == "access" then
- c[1] = {i,j}
- c[2] = {k,l}
- loop = false
- 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
- break
- end
- if login.access then
- else
- end
- print(login.access)
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment