Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- serverID = 0
- function TestConnection(debug)
- if debug == "true" then
- print("Debug: sending ping")
- function ping()
- rednet.send(serverID, "ping")
- local senderID, message, distance = rednet.receive(5)
- if message == "server_busy" then
- print("Server is busy, Retrying in 10 seconds")
- sleep(10)
- ping()
- end
- if message == "pong" then
- else
- error("The server didn't respond, the server may be out dated, not online, or you don't have a strong enough connection.")
- end
- end
- ping()
- print("Debug: Server: ", senderID, " Connecion Message: ", message)
- sleep(0.5)
- else
- rednet.send(serverID, "ping")
- local senderID, message, distance = rednet.receive()
- sleep(0.5)
- end
- end
- function connect(loginName, loginPass)
- rednet.send(serverID, "domain_connect")
- sleep(0.5)
- rednet.send(serverID, loginName)
- sleep(0.5)
- rednet.send(serverID, loginPass)
- end
- function disconnect()
- print("Attempting safe disconnection.")
- rednet.send(serverID, "domain_disconnect")
- local senderID, message, distance = rednet.receive()
- if message == "disconnected" then
- print("Logout complete! Killing rednet modem.", " ", senderID, message, distance)
- rednet.close("top")
- else
- print("Failed safe disconnection, killing connection.")
- rednet.close("top")
- end
- end
Add Comment
Please, Sign In to add comment