Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Router
- local timeout = 0.5
- function start()
- rednet.open("top")
- local password = 55631
- local id, message = rednet.receive()
- if (message) ~= nil then
- if message == "SD" then
- if fs.exists("network/"..id) then
- rednet.send(id,"data")
- local iid,sid = rednet.receive()
- local iid,smessage = rednet.receive()
- rednet.send(tonumber(sid),smessage)
- local rid,check = rednet.receive(timeout)
- if not check then
- print("false")
- rednet.send(id,"0")
- start()
- else
- print("true")
- rednet.send(id,"1")
- start()
- end
- end
- elseif tonumber(message) == tonumber(password) then
- if fs.exists("network/"..id) then
- rednet.send(tonumber(id),"connected!")
- print("Client "..id.." connected!")
- start()
- else
- rednet.send(tonumber(id),"Type!")
- local id, tp = rednet.receive()
- print(tp)
- local file = fs.open("network/"..id,"w")
- file.writeLine(id)
- file.writeLine(tp)
- file.close()
- rednet.send(id,"connected!")
- print("Client "..id.." connected!")
- sleep(.2)
- os.reboot()
- end
- else
- print(message)
- rednet.send(id,"!")
- sleep(5)
- os.reboot()
- end
- end
- end
- start()
Add Comment
Please, Sign In to add comment