Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ LanteaCraft & SGCraft ]]--
- --[[ DiscoveryDialer ]]--
- --[[ by Dog ]]--
- --[[ aka ]]--
- --[[ HydrantHunter ]]--
- --[[ pastebin: BiXu3DfW ]]--
- local tArgs = { ... }
- local gate = peripheral.find("stargate")
- if not gate then print("") print("No stargate found!") print("") return end
- local lcGate = pcall(gate.getAddress)
- local thisGate = lcGate and gate.getAddress() or gate.localAddress()
- if not lcGate and #thisGate == 7 then print("") print("discoDialer requires a 9 chevron gate.") print("") return end
- local symbols = { 'A', 'B', 'C', 'D', 'E' ,'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '+' }
- local startChevron = { [1] = 1, [2] = 1, [3] = 1, [4] = 1, [5] = 1, [6] = 1, [7] = 1, [8] = 1, [9] = 1 }
- local newAddress = 'AAAAAAAAA'
- local numDials, numGates, numErrors = 0, 0, 0
- local gateStatus, stopMe = false, false
- local function loadSession()
- local file = fs.open(".discoverySession", "r")
- newAddress = file.readLine()
- file.close()
- end
- local function saveSession()
- local file = fs.open(".discoverySession", "w")
- file.writeLine(newAddress)
- file.close()
- end
- local function recordGate()
- local file = fs.open("gateList", fs.exists("gateList") and "a" or "w")
- file.writeLine(newAddress)
- file.close()
- end
- local function gateWatch()
- while true do
- local event, success, newState = os.pullEvent()
- if lcGate then
- if event == "sgIdle" then
- return false
- elseif event == "sgWormholeOpening" and success then
- return true
- end
- else
- if event == "sgStargateStateChange" and newState == "Idle" then
- return false
- elseif event == "sgStargateStateChange" and newState == "Connected" then
- return true
- end
- end
- end
- end
- local function gateDialer()
- while true do
- local checkAddress, _ = pcall(gate.dial, newAddress)
- print("Dialing " .. newAddress)
- if checkAddress then
- numDials = numDials + 1
- gateStatus = gateWatch()
- break
- else
- if lcGate then
- print("Unable to dial")
- numErrors = numErrors + 1
- if numErrors >= 10 then numErrors = 0 return end
- sleep(2)
- else
- numDials = numDials + 1
- gateStatus = false
- break
- end
- end
- end
- if gateStatus and ((lcGate and gate.isConnected()) or (not lgGate and gate.stargateState() == "Connected")) then
- print("Found gate at " .. newAddress)
- numGates = numGates + 1
- recordGate(newAddress)
- gateStatus = false
- pcall(gate.disconnect)
- sleep(2)
- end
- end
- local function gateScanner(chevronEIGHT, chevronNINE)
- for chevronONE = startChevron[1], #symbols do
- for chevronTWO = startChevron[2], #symbols do
- for chevronTHREE = startChevron[3], #symbols do
- for chevronFOUR = startChevron[4], #symbols do
- for chevronFIVE = startChevron[5], #symbols do
- for chevronSIX = startChevron[6], #symbols do
- for chevronSEVEN = startChevron[7], #symbols do
- newAddress = symbols[chevronONE] .. symbols[chevronTWO] .. symbols[chevronTHREE] .. symbols[chevronFOUR] .. symbols[chevronFIVE] .. symbols[chevronSIX] .. symbols[chevronSEVEN] .. symbols[chevronEIGHT] .. symbols[chevronNINE]
- if newAddress ~= thisGate then
- print("Temporal buffer...")
- sleep(1)
- saveSession()
- gateDialer()
- end
- end
- end
- end
- end
- end
- end
- end
- end
- local function dimensionScanner()
- if tArgs and tArgs[1] and type(tArgs[1]) == "string" and #tArgs[1] == 2 then
- local chevronEIGHT, chevronNINE
- for i = 1, #symbols do
- if tArgs[1]:sub(1, 1) == symbols[i] then chevronEIGHT = i end
- if tArgs[1]:sub(2) == symbols[i] then chevronNINE = i end
- end
- gateScanner(chevronEIGHT, chevronNINE)
- stopMe = true
- else
- for chevronEIGHT = startChevron[8], #symbols do
- for chevronNINE = startChevron[9], #symbols do
- gateScanner(chevronEIGHT, chevronNINE)
- end
- end
- stopMe = true
- end
- end
- local function quit()
- local _, char = os.pullEvent("char")
- if string.lower(char) == "q" then
- pcall(gate.disconnect)
- stopMe = true
- end
- end
- if fs.exists("warSession") then
- fs.move("warSession", ".discoverySession")
- end
- if fs.exists(".discoverySession") then
- loadSession()
- for i = 1, 9 do
- for j = 1, #symbols do
- if newAddress:sub(i, i) == symbols[j] then
- startChevron[i] = j
- break
- end
- end
- end
- end
- while true do
- parallel.waitForAny(dimensionScanner, quit)
- if stopMe or numErrors >= 10 then break end
- end
- print("")
- print("")
- print("Dialed " .. tostring(numDials) .. " addresses in " .. tostring(numDials + numErrors) .. " tries")
- print("")
- print("Had " .. tostring(numErrors) .. " errors")
- print("")
- print("Found " .. tostring(numGates) .. " gates")
- print("")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement