Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function isWired(_, o)
- return not o.isWireless()
- end
- function isWireless(_, o)
- return o.isWireless()
- end
- local remote = peripheral.find("modem", isWireless)
- if not remote then
- print("Please connect a wireless modem to the network")
- while not peripheral.find("modem", isWireless) do
- os.sleep(1)
- end
- remote = peripheral.find("modem", isWireless)
- end
- if not settings.get("cc") then
- local modem = peripheral.find("modem", isWired)
- local drive = peripheral.find("drive")
- if not modem then
- print("Please connect the computer to the registration network")
- while not peripheral.find("modem", isWired) do
- os.sleep(1)
- end
- modem = peripheral.find("modem", isWired)
- end
- if not drive then
- print("Please connect a drive to the network")
- while not peripheral.find("drive") do
- os.sleep(1)
- end
- drive = peripheral.find("drive")
- end
- modem.open(42424)
- local Scode = "SQTV3REG-S-" .. string.format("%04d", os.getComputerID())
- local Fcode = "SQTV3REG-F-" .. string.format("%04d", os.getComputerID())
- print("waiting connection message")
- while true do
- local msg = select(5, os.pullEvent("modem_message"))
- if msg == Scode then
- modem.transmit(42424, os.getComputerID(), Scode)
- end
- if msg == Fcode then
- modem.transmit(42424, os.getComputerID(), Fcode)
- settings.load("disk/uuid")
- settings.save()
- modem.close(42424)
- break
- end
- end
- end
- local uuid = settings.get("uuid")
- local tchannel = settings.get("cc")
- local cid = settings.get("cid")
- print("Turtle Loaded with ID " .. uuid)
- print("Attempting to connect to the server...")
- remote.open(tchannel)
- while not connected do
- os.startTimer(5)
- remote.transmit(tchannel, tchannel, string.format("SQTV3-%04d-CREQ-%s", cid, uuid))
- local event, _, channel, reply, msg = os.pullEvent()
- if event == "modem_message" and msg == string.format("SQTV3-%04d-CON", cid) then
- print("Connected")
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement