Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local w, h = term.getSize()
- function printCentered(text, y)
- term.setCursorPos(w/2 - #text/2, y)
- term.write(text)
- end
- term.clear()
- term.setCursorPos(1, 1)
- print(string.rep("-", w))
- printCentered("Welcome to the GraviNet Setup wizard.", 2)
- printCentered("This wizard will guide you", 3)
- printCentered("through connecting to GraviNet.", 4)
- print(string.rep("-", w))
- os.sleep(0.5)
- print("\n")
- print("Which side is your modem on?")
- print("[top, bottom, back, front, left, right]")
- local side = read()
- print("Modem at side: "..side)
- os.sleep(0.5)
- print("Attempting to connect to GraviNet, please wait.")
- rednet.open(side)
- rednet.broadcast("$HELLO")
- local id, message
- while true do
- id, message = rednet.receive(5)
- if not message then
- error("No network routers nearby, couldn't connect to GraviNet.")
- return
- end
- if message == "$HELLO" then break end
- end
- print("A network has been located!")
- rednet.send(id, "$ADDME")
- while true do
- id, message = rednet.receive(5)
- if not message then
- error("Connecting failed... Network did not accept your computer.")
- return
- end
- if message == "$ACK" then break end
- end
- print("Succesfully connected to GraviNet. Updating your preferences...")
- local pref = fs.open("gravinet/client/pref", "w")
- pref.write(textutils.serialise({
- routerId = id,
- side = side
- }))
- pref.close()
- os.sleep(0.5)
- term.clear()
- term.setCursorPos(1,1)
- print("A preference file has been created in the directory gravinet/pref . Do not delete this file!")
- os.sleep(0.5)
- print("Connection to network succesful, shutting down wizard...")
- os.sleep(1)
- rednet.close(side)
- term.clear()
- term.setCursorPos(1,1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement