34 lines
787 B
Lua
34 lines
787 B
Lua
|
|
||
|
io.write("Enter the hostname: ")
|
||
|
hostname = io.read()
|
||
|
|
||
|
io.write("Enter the modem location: ")
|
||
|
modem_location = io.read()
|
||
|
|
||
|
io.write("Use default LNS Server? (y/n): ")
|
||
|
use_default = io.read()
|
||
|
|
||
|
lns_server = "default"
|
||
|
if use_default == "n" then
|
||
|
io.write("Enter the LNS Server Rednet Hostname: ")
|
||
|
lns_server = io.read()
|
||
|
end
|
||
|
|
||
|
rednet.open(modem_location)
|
||
|
receiverID = rednet.lookup("lns", lns_server)
|
||
|
current_time = os.time()
|
||
|
rednet.send(receiverID, "register:" .. hostname)
|
||
|
|
||
|
while true do
|
||
|
id, msg = rednet.receive()
|
||
|
if msg == "ok" then
|
||
|
print("Registered with LNS Server Successfully!")
|
||
|
break
|
||
|
end
|
||
|
|
||
|
-- timeout after 5 seconds
|
||
|
if os.time() - current_time > 5 then
|
||
|
print("Failed to register with LNS Server! Timeout!")
|
||
|
break
|
||
|
end
|
||
|
end
|