Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ LanteaCraft ]]--
- --[[ and SGCraft ]]--
- --[[ Gate Liaison ]]--
- --[[ by Dog ]]--
- --[[ aka HydrantHunter ]]--
- --[[ with help from ]]--
- --[[ AfterLifeLochie ]]--
- --[[ pastebin PLy9GAWt ]]--
- local gVer = "1.5.02"
- --[[
- Tested with/requires:
- - Minecraft 1.7.10
- - LanteaCraft-1.7.10-70 || SGCraft1.95-mc1.7.10
- - ComputerCraft 1.73, 1.74, 1.75
- - A computer (standard or advanced), 1 or more optional 3x Monitor Arrays (standard or advanced)
- - or a wireless turtle (standard or advanced), no monitors
- - A stargate with a CC adapter
- - ccDHD running on an advanced computer with a wireless modem
- ]]--
- --# AUTOMATIC/STATIC CONFIGURATION (Part 1)
- local mon = { }
- local modem, gate, secureStatus, thisGate, incomingAddress, fuelGauge, doCommand, gateStateChange
- local lcGate, irisState, staticDrawn = false, false, false
- local gateStatus, dialAddress, modemSide, chevronNumber, maxFuel = "QRY", "none", "none", 0, 203842
- local gateSettings = {
- rsSide = "front",
- DHD = 99999,
- }
- --# Color Definitions
- local white = colors.white
- local silver = colors.lightGray
- local gray = colors.gray
- local black = colors.black
- local brown = colors.brown
- local yellow = colors.yellow
- local orange = colors.orange
- local red = colors.red
- local magenta = colors.magenta
- local purple = colors.purple
- local blue = colors.blue
- local sky = colors.lightBlue
- local cyan = colors.cyan
- local lime = colors.lime
- local green = colors.green
- if not term.isColor() then
- silver = colors.white
- gray = colors.black
- brown = colors.white
- yellow = colors.white
- orange = colors.white
- red = colors.white
- magenta = colors.white
- purple = colors.white
- blue = colors.black
- sky = colors.white
- cyan = colors.white
- lime = colors.white
- green = colors.white
- end
- local mwhite = colors.white
- local msilver = colors.lightGray
- local mgray = colors.gray
- local mblack = colors.black
- local mbrown = colors.brown
- local myellow = colors.yellow
- local morange = colors.orange
- local mred = colors.red
- local mmagenta = colors.magenta
- local mpurple = colors.purple
- local mblue = colors.blue
- local msky = colors.lightBlue
- local mcyan = colors.cyan
- local mlime = colors.lime
- local mgreen = colors.green
- --# END AUTOMATIC/STATIC CONFIGURATION (Part 1)
- local function shutDown()
- rednet.close(modemSide)
- if mon[1] then
- for i = 1, #mon do
- mon[i].setBackgroundColor(mblack)
- mon[i].clear()
- end
- end
- end
- local function ingestData()
- local gateConfig = fs.open("/data/gateConfig", "r") or function() shutDown() error("ingestData(): Unable to open /data/gateConfig for reading", 0) end
- gateSettings = textutils.unserialize(gateConfig.readAll())
- gateConfig.close()
- end
- local function saveData()
- local gateConfig = fs.open("/data/gateConfig", "w") or function() shutDown() error("saveData(): Unable to open /data/gateConfig for writing", 0) end
- gateConfig.write(textutils.serialize(gateSettings))
- gateConfig.close()
- end
- local function netSend()
- local dataPack = {
- program = "ccDHD",
- thisGate = thisGate,
- fuelGauge = fuelGauge,
- gateStatus = gateStatus,
- secureStatus = secureStatus,
- dialAddress = dialAddress,
- incomingAddress = incomingAddress,
- chevronNumber = chevronNumber,
- irisState = irisState,
- lcGate = lcGate,
- }
- if not rednet.isOpen(modemSide) then
- rednet.open(modemSide)
- end
- if gateSettings.DHD ~= 99999 then
- rednet.send(gateSettings.DHD, dataPack)
- end
- end
- local function netReceive()
- while true do
- local id, message = rednet.receive()
- if id == gateSettings.DHD and type(message) == "table" then
- if message.program == "ccDHD" then
- doCommand(message.command)
- elseif message.program == "pSync" and message.password then
- if not lcGate then
- gate.sendMessage(message.password)
- end
- end
- end
- end
- end
- local function gateReceive()
- while true do
- local _, src, password = os.pullEvent("sgMessageReceived")
- if gateSettings.DHD ~= 99999 then
- rednet.send(gateSettings.DHD, password)
- end
- end
- end
- local function makeLongName(name)
- return #name ~= 7 and name or table.concat({ name:sub(1, 1), " ", name:sub(2, 2), " ", name:sub(3, 3), " ", name:sub(4, 4), " ", name:sub(5, 5), " ", name:sub(6, 6), " ", name:sub(7) })
- end
- local function displayMarquee() --# Display the local address when there is no other information to display
- if not mon[1] then return end
- if secureStatus == "allclear" then
- for i = 1, #mon do
- mon[i].setBackgroundColor(mblack)
- mon[i].clear()
- mon[i].setCursorPos(1, 1)
- mon[i].setTextColor(mcyan)
- mon[i].write("Stargate")
- mon[i].setTextColor(myellow)
- mon[i].setCursorPos(4, 2)
- mon[i].write(thisGate)
- end
- else
- for i = 1, #mon do
- mon[i].setBackgroundColor(mblack)
- mon[i].clear()
- mon[i].setCursorPos(1, 1)
- mon[i].setTextColor(mred)
- mon[i].write("!! LOCKDOWN !!")
- end
- end
- end
- local function displayStatus(select)
- if not mon[1] then return end
- if select == "dial" or (select == "con" and not incomingAddress) then
- local longAddress = makeLongName(dialAddress)
- for i = 1, #mon do
- mon[i].setCursorPos(1, 1)
- mon[i].setTextColor(msky)
- if select == "dial" then
- mon[i].write("Dialing ")
- mon[i].setTextColor(mgray)
- elseif select == "con" then
- mon[i].write("Connected to")
- mon[i].setTextColor(myellow)
- end
- mon[i].setCursorPos(#dialAddress - 5, 2)
- mon[i].write(#dialAddress == 9 and dialAddress or longAddress)
- end
- elseif select == "incoming" or (select == "con" and incomingAddress) then
- local longAddress = makeLongName(incomingAddress)
- for i = 1, #mon do
- mon[i].setTextColor(secureStatus == "allclear" and myellow or mred)
- mon[i].setCursorPos(1, 1)
- mon[i].write("Incoming from ")
- mon[i].setTextColor(secureStatus == "allclear" and msky or morange)
- if (lcGate and gate.isDialing()) or (not lcGate and gate.stargateState() == "Dialling") then
- if lcGate then
- mon[i].setCursorPos(4, 2)
- mon[i].write(incomingAddress .. string.rep(" ", 13))
- else
- mon[i].setCursorPos(#incomingAddress - 5, 2)
- if #incomingAddress == 7 then
- mon[i].write(longAddress:sub(1, chevronNumber * 2))
- mon[i].setTextColor(mgray)
- mon[i].write(longAddress:sub((chevronNumber * 2) + 1, #longAddress))
- else
- mon[i].write(incomingAddress:sub(1, chevronNumber))
- mon[i].setTextColor(mgray)
- mon[i].write(incomingAddress:sub(chevronNumber + 1, #incomingAddress))
- end
- end
- else
- mon[i].setCursorPos(#incomingAddress - 5, 2)
- mon[i].write(longAddress)
- end
- end
- elseif select == "outgoing" then
- local longAddress = makeLongName(dialAddress)
- for i = 1, #mon do
- mon[i].setCursorPos(#dialAddress - 5, 2)
- mon[i].setTextColor(myellow)
- if #dialAddress == 7 then
- mon[i].write(longAddress:sub(1, chevronNumber * 2))
- else
- mon[i].write(dialAddress:sub(1, chevronNumber))
- end
- end
- elseif select == "discon" then
- for i = 1, #mon do
- mon[i].clear()
- mon[i].setCursorPos(1, 1)
- mon[i].setTextColor(msky)
- mon[i].write(gateStatus)
- end
- end
- end
- local function drawElement(x, y, w, h, txtColor, bgColor, text)
- if bgColor then term.setBackgroundColor(bgColor) end
- local deText = text and tostring(text) or ""
- if w > #deText or h > 1 then --# We're drawing something more than text
- local line = string.rep(" ", w) --# Define one line of the 'element' (box/rectangle/line-seg)
- for i = y, y + h - 1 do
- term.setCursorPos(x, i) --# Position cursor
- term.write(line) --# Draw 1 of h lines of the 'element' (box/rectangle/line-seg)
- end
- end
- if deText ~= "" then
- if txtColor then term.setTextColor(txtColor) end
- w = math.max(w, #deText) --# Ensure minimum length
- local xW = (x + math.floor(w / 2)) - math.floor(#deText / 2) --# Center the text horizontally
- local yH = y + math.floor(h / 2) --# Center the text vertically
- term.setCursorPos(xW, yH) --# Set the cursor position
- term.write(deText) --# Write the text
- end
- end
- local function terminalScreen()
- local stColor, sbColor
- --# Set the header color
- if term.isColor() then
- stColor = mon[1] and white or black
- sbColor = mon[1] and blue or sky
- if lcGate then
- stColor = fuelGauge and stColor or white
- sbColor = fuelGauge and sbColor or red
- else
- stColor = fuelGauge > math.floor(maxFuel * 0.05) and stColor or white
- sbColor = fuelGauge > math.floor(maxFuel * 0.05) and sbColor or red
- end
- else
- stColor = black
- sbColor = white
- end
- --# Draw header (not 'static' - color changes based on fuel/monitor status)
- local glHeaderTxt = " Gate Liaison" .. string.rep(" ", 12) .. "ver. " .. gVer .. " "
- drawElement(2, 2, 1, 1, stColor, sbColor, glHeaderTxt) --# Header
- drawElement(2, 10, 37, 1, nil, nil, "") --# Footer
- drawElement(3, 10, 1, 1, nil, nil, os.getComputerLabel()) --# Lowline
- local cID = "cc # " .. tostring(os.getComputerID())
- drawElement(38 - #cID, 10, 1, 1, stColor, sbColor, cID)
- --# Static entries
- if not staticDrawn then
- drawElement(2, 3, 12, 7, nil, silver, "") --# Labels' background
- local readouts = { " Gate:", " State:", " Target:", " Iris:", " Fuel:", " Status:", " Network:" }
- for i = 1, 7 do
- drawElement(2, i + 2, 1, 1, black, nil, readouts[i])
- end
- drawElement(17, 3, 1, 1, yellow, black, thisGate)
- drawElement(17, 9, 1, 1, red, nil, "redNet " .. gateSettings.DHD)
- drawElement(26, 9, 1, 1, gray, nil, "ccDHD")
- staticDrawn = true
- end
- --# Dynamic entries
- local sTxtColor = blue
- if gateStatus == "Disconnected" then
- sTxtColor = green
- elseif gateStatus == "Connected" then
- sTxtColor = orange
- elseif gateStatus == "Dialing" or gateStatus == "Disconnecting" then
- sTxtColor = sky
- end
- if gateStatus == "Dialing" and dialAddress == "none" then
- drawElement(17, 4, 1, 1, sTxtColor, black, incomingAddress and "Incoming" or "Incoming Connection")
- elseif secureStatus == "lockdown" and not incomingAddress then
- drawElement(17, 4, 1, 1, red, black, "!! LOCKDOWN !!")
- else
- drawElement(17, 4, 1, 1, sTxtColor, black, gateStatus .. string.rep(" ", 11))
- end
- drawElement(17, 5, 1, 1, brown, black, (dialAddress == "none" and incomingAddress) and incomingAddress .. string.rep(" ", 13) or dialAddress .. string.rep(" ", 5))
- drawElement(17, 6, 1, 1, irisState and green or orange, black, irisState and "CLOSED" or "OPEN ")
- if lcGate then
- drawElement(17, 7, 1, 1, fuelGauge and green or red, nil, fuelGauge and "YES " or "NO ")
- else
- drawElement(17, 7, 1, 1, fuelGauge > math.floor(maxFuel * 0.05) and green or orange, nil, tostring(math.floor((fuelGauge / maxFuel) * 100)))
- term.setTextColor(silver)
- term.write("% ")
- end
- drawElement(17, 8, 1, 1, secureStatus == "allclear" and green or red, nil, secureStatus)
- end
- local function updateStatus()
- if lcGate then
- irisState = rs.getOutput(gateSettings.rsSide)
- fuelGauge = gate.hasFuel()
- else
- local iris = gate.irisState()
- if iris == "Open" or iris == "Closing" or iris == "Offline" then
- irisState = false
- elseif iris == "Closed" or iris == "Opening" then
- irisState = true
- end
- fuelGauge = gate.energyAvailable()
- end
- if incomingAddress or dialAddress ~= "none" then
- if mon[1] then
- if gateStatus == "Dialing" then
- displayStatus(incomingAddress and "incoming" or "dial") --# incoming or outgoing
- elseif gateStatus == "Connected" then
- displayStatus("con")
- end
- end
- end
- if gateStatus == "Disconnected" then
- displayMarquee()
- elseif gateStatus == "Disconnecting" then
- displayStatus("discon")
- end
- netSend()
- terminalScreen()
- end
- local function recordSessionData() --# Human readable log files (last gate & history)
- local logAddress = incomingAddress or dialAddress
- local callDirection = incomingAddress and "Inbound" or "Outbound"
- local tTime = textutils.formatTime(os.time(), false)
- local lastCall = fs.open("/data/gateLastCall", "w")
- lastCall.writeLine(tostring(os.day()) .. " @ " .. tTime .. " <" .. callDirection .. "> " .. logAddress)
- lastCall.close()
- end
- local function irisControl(state)
- if lcGate then
- rs.setOutput(gateSettings.rsSide, state)
- else
- if state then
- pcall(gate.closeIris)
- else
- pcall(gate.openIris)
- end
- end
- end
- local function dialOut(targetAddress)
- if secureStatus == "allclear" then
- dialAddress = targetAddress
- local dialGate, _ = pcall(gate.dial, dialAddress)
- if dialGate then
- gateStatus = "Dialing"
- updateStatus()
- end
- return dialGate
- else
- return false
- end
- end
- local function hangUp()
- if gateStatus == "Disconnected" then return true end
- local onHook, _ = pcall(gate.disconnect)
- if onHook then
- gateStatus = "Disconnecting"
- dialAddress = "none"
- incomingAddress = nil
- chevronNumber = 0
- end
- return onHook
- end
- local function lockDown()
- secureStatus = "lockdown"
- irisControl(true)
- return hangUp()
- end
- do
- local actions = {
- lockdown = function()
- lockDown()
- updateStatus()
- end,
- allclear = function()
- secureStatus = "allclear"
- irisControl(false)
- updateStatus()
- end,
- QRY = function()
- updateStatus()
- end,
- endCall = function()
- hangUp()
- updateStatus()
- end,
- iCLOSE = function(_lcGate)
- irisControl(true)
- if _lcGate then updateStatus() end
- end,
- iOPEN = function(_lcGate, _secureStatus)
- if _secureStatus == "allclear" then
- irisControl(false)
- if _lcGate then updateStatus() end
- end
- end,
- }
- doCommand = function(thisCommand)
- for cmd, func in pairs(actions) do
- if thisCommand == cmd then
- return func(lcGate, secureStatus)
- end
- end
- if #thisCommand == 7 or #thisCommand == 9 then
- if not dialOut(thisCommand) then
- dialAddress = "none"
- end
- else
- dialAddress = "none"
- end
- updateStatus()
- end
- end
- local function irisStateChange() --# SGCraft
- while true do
- local irisEvent, _, newState, oldState = os.pullEvent("sgIrisStateChange")
- if newState == "Closed" or newState == "Open" or newState == "Offline" then
- updateStatus()
- end
- end
- end
- do
- local states = {
- Idle = "Disconnected",
- Dialling = "Dialing",
- Opening = "Dialing",
- Connected = "Connected",
- Closing = "Disconnecting",
- Offline = "Disconnected",
- }
- gateStateChange = function() --# SGCraft
- while true do
- local sgEvent, _, new_State, old_State = os.pullEvent("sgStargateStateChange")
- gateStatus = states[new_State]
- if gateStatus == "Disconnecting" or gateStatus == "Disconnected" then
- dialAddress = "none"
- incomingAddress = nil
- chevronNumber = 0
- end
- if gateStatus ~= "Dialing" then updateStatus() end
- end
- end
- end
- local function chevronEncoder() --# SGCraft
- while true do
- local sgEvent, _, chevron
- sgEvent, _, chevronNumber, chevron = os.pullEvent("sgChevronEngaged")
- if incomingAddress then
- displayStatus("incoming")
- drawElement(17, 5, 1, 1, cyan, black, incomingAddress:sub(1, chevronNumber))
- else
- displayStatus("outgoing")
- drawElement(17, 5, 1, 1, cyan, black, dialAddress:sub(1, chevronNumber))
- end
- netSend()
- end
- end
- local function outgoingCall() --# LanteaCraft & SGCraft
- local sgEvent, _
- while true do
- if lcGate then
- sgEvent, chevronNumber = os.pullEvent("sgChevronEncode")
- else
- sgEvent, _, dialAddress = os.pullEvent("sgDialOut")
- chevronNumber = 1
- end
- if dialAddress ~= "none" then
- displayStatus("outgoing")
- drawElement(17, 5, 1, 1, cyan, black, dialAddress:sub(1, chevronNumber))
- netSend()
- end
- end
- end
- local function incomingCall() --# LanteaCraft & SGCraft
- while true do
- local sgEvent, _, incomingChevron
- if lcGate then
- _, incomingChevron = os.pullEvent("sgIncoming")
- else
- sgEvent, _, incomingAddress = os.pullEvent("sgDialIn")
- end
- gateStatus = "Dialing"
- if lcGate then
- if not incomingChevron then
- drawElement(17, 4, 1, 1, orange, black, "Incoming Connection")
- else
- incomingAddress = incomingAddress and incomingAddress .. incomingChevron or incomingChevron
- drawElement(17, 4, 1, 1, orange, black, "Incoming ")
- drawElement(17, 5, 1, 1, brown, nil, incomingAddress .. string.rep(" ", 13))
- end
- else
- if not incomingAddress then
- drawElement(17, 4, 1, 1, orange, black, "Incoming Connection")
- else
- drawElement(17, 4, 1, 1, orange, black, "Incoming ")
- drawElement(17, 5, 1, 1, brown, nil, incomingAddress .. string.rep(" ", 13))
- end
- end
- displayStatus("incoming")
- netSend()
- end
- end
- local function callConnect() --# LanteaCraft
- while true do
- os.pullEvent("sgWormholeOpening")
- gateStatus = "Connected"
- recordSessionData()
- updateStatus()
- end
- end
- local function callDisconnect() --# LanteaCraft
- while true do
- os.pullEvent("sgWormholeClosing")
- gateStatus = "Disconnecting"
- dialAddress = "none"
- incomingAddress = nil
- chevronNumber = 0
- updateStatus()
- end
- end
- local function gateIdle() --# LanteaCraft
- while true do
- os.pullEvent("sgIdle")
- gateStatus = "Disconnected"
- dialAddress = "none"
- incomingAddress = nil
- chevronNumber = 0
- updateStatus()
- end
- end
- local function charInput()
- while true do
- local _, char = os.pullEvent("char")
- if string.lower(char) == "q" then
- term.setBackgroundColor(colors.black)
- term.clear()
- drawElement(1, 1, 1, 1, white, nil, "gateLiaison is OFFLINE")
- term.setCursorPos(1, 3)
- return
- end
- end
- end
- local function waitingAnimation() --# intentionally not using drawELement - much more efficient
- while true do
- for i = 5, 21 do
- term.setCursorPos(i, 11)
- term.setBackgroundColor(cyan)
- term.write(" ")
- term.setBackgroundColor(black)
- term.setCursorPos(i - 1, 11)
- term.write(" ")
- sleep(0.04)
- end
- for i = 21, 5, -1 do
- term.setCursorPos(i, 11)
- term.setBackgroundColor(cyan)
- term.write(" ")
- term.setBackgroundColor(black)
- term.setCursorPos(i + 1, 11)
- term.write(" ")
- sleep(0.04)
- end
- end
- end
- local function waitingNet()
- while true do
- local id, message = rednet.receive()
- if type(message) == "table" and message.program == "ccDHD" and message.command == "1stRun" then
- gateSettings.DHD = id
- netSend()
- rednet.unhost("ccDHDSetup")
- return
- end
- end
- end
- local function firstRun()
- local ccLabel = os.getComputerLabel() --# Set computer label
- if ccLabel == nil or tostring(ccLabel) == "" or ccLabel == "Gate" then
- os.setComputerLabel(thisGate .. " gate")
- end
- term.setBackgroundColor(black)
- if lcGate then
- term.clear()
- drawElement(2, 2, 1, 1, white, black, "Please select a redstone output side") --# Select redstone output side
- drawElement(2, 3, 1, 1, nil, nil, "(select an unused side if not using")
- drawElement(2, 4, 1, 1, nil, nil, " redstone)")
- for k, v in ipairs(rs.getSides()) do --# Draw side list
- local sSides = tostring(k) .. " = " .. string.upper(v):sub(1, 1) .. v:sub(2)
- drawElement(2, k + 5, #sSides, 1, nil, nil, sSides)
- end
- while true do --# Get rsSide user choice
- term.setCursorPos(2, 13)
- local getSide = tonumber(read())
- if getSide ~= nil then
- if getSide > 0 and getSide < 7 then
- for k, v in ipairs(rs.getSides()) do
- if getSide == k then
- gateSettings.rsSide = v
- break
- end
- end
- break
- end
- end
- end
- end
- term.clear()
- drawElement(2, 2, 1, 1, nil, nil, "Please start ccDHD to complete setup.")
- drawElement(2, 4, 1, 1, nil, nil, "gateLiaison will automatically start")
- drawElement(2, 5, 1, 1, nil, nil, "after ccDHD is initialized.")
- drawElement(2, 7, 1, 1, nil, nil, "This gate: " .. thisGate)
- rednet.host("ccDHDSetup", thisGate)
- drawElement(2, 9, 1, 1, silver, nil, "...waiting for ccDHD...")
- parallel.waitForAny(waitingNet, waitingAnimation)
- term.clear()
- end
- --# AUTOMATIC/STATIC CONFIGURATION (Part 2)
- local function initError(device)
- term.setBackgroundColor(black)
- term.clear()
- drawElement(1, 1, 1, 1, red, black, "No " .. device .. " detected!")
- drawElement(1, 3, 1, 1, white, nil, "gateLiaison is OFFLINE")
- term.setCursorPos(1, 5)
- return false
- end
- local function initGate()
- gate = peripheral.find("stargate")
- if not gate then return initError("Stargate") end
- lcGate = pcall(gate.getAddress)
- if lcGate then
- thisGate = gate.getAddress()
- fuelGauge = gate.hasFuel()
- gateStatus = gate.isConnected() and "Connected" or "Disconnected"
- gateStatus = gate.isDialing() and "Dialing" or gateStatus
- else
- thisGate = gate.localAddress()
- fuelGauge = gate.energyAvailable()
- local gateState, callDirection
- gateState, chevronNumber, callDirection = gate.stargateState()
- local states = {
- Idle = "Disconnected",
- Dialling = "Dialing",
- Opening = "Connected",
- Connected = "Connected",
- Closing = "Disconnecting",
- Offline = "Offline",
- }
- gateStatus = states[gateState]
- if gateStatus == "Offline" then return initError("Stargate") end
- if gateStatus == "Dialing" or gateStatus == "Connected" then
- if callDirection == "Inbound" then
- incomingAddress = gate.remoteAddress()
- else
- dialAddress = gate.remoteAddress()
- end
- end
- end
- return true
- end
- local function initMe()
- print("Init Gate...")
- if not initGate() then return false end
- print("Init Modem & Monitor...")
- local bAndW = false --# black and white monitor tracker
- for _, side in ipairs(rs.getSides()) do
- if peripheral.getType(side) == "modem" then
- if peripheral.call(side, "isWireless") then
- modemSide = side
- else
- local mPerps = peripheral.call(tostring(side), "getNamesRemote")
- for _, name in ipairs(mPerps) do
- if name:sub(1, 7) == "monitor" then
- peripheral.call(name, "setTextScale", 1)
- local tmX, tmY = peripheral.call(name, "getSize")
- if tmX >= 29 then
- mon[#mon + 1] = peripheral.wrap(name)
- if not mon[#mon].isColor() then
- bAndW = true --# black and white monitor found
- end
- end
- end
- end
- end
- end
- end
- if modemSide == "none" then
- return initError("Wireless Modem")
- end
- rednet.open(modemSide)
- if bAndW then --# if a black and white monitor was found, reset monitor colors to black and white
- msilver = colors.white
- mgray = colors.black
- mbrown = colors.white
- myellow = colors.white
- morange = colors.white
- mred = colors.white
- mmagenta = colors.white
- mpurple = colors.white
- mblue = colors.black
- msky = colors.white
- mcyan = colors.white
- mlime = colors.white
- mgreen = colors.white
- end
- --# Check for first time install
- print("Inspect Environment...")
- if not fs.exists("/data/gateConfig") then
- print("First Run...")
- if not fs.exists("/data") then fs.makeDir("/data") end
- firstRun()
- saveData()
- else
- print("Ingest Data...")
- ingestData()
- end
- if mon[1] then
- for i = 1, #mon do
- mon[i].setBackgroundColor(mwhite)
- mon[i].setTextColor(mblack)
- mon[i].clear()
- mon[i].setTextScale(2)
- mon[i].setCursorPos(2, 1)
- mon[i].write("gateLiaison")
- mon[i].setCursorPos(2, 2)
- mon[i].write("Initializing")
- end
- end
- secureStatus = "allclear"
- return true
- end
- --# END AUTOMATIC/STATIC CONFIGURATION (Part 2)
- if not initMe() then return end
- term.setBackgroundColor(black)
- term.clear()
- if mon[1] then
- for i = 1, #mon do
- mon[i].setBackgroundColor(black)
- mon[i].clear()
- end
- end
- updateStatus()
- if lcGate then
- parallel.waitForAny(netReceive, incomingCall, outgoingCall, callConnect, callDisconnect, gateIdle, charInput)
- else
- parallel.waitForAny(gateReceive, netReceive, incomingCall, chevronEncoder, gateStateChange, irisStateChange, charInput)
- end
- shutDown()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement