And it's fixed, but also another problem happened. Lets fix that too

This commit is contained in:
2026-01-02 00:17:57 -05:00
parent 9224f22395
commit d11641693b
2 changed files with 104 additions and 60 deletions

View File

@ -6,7 +6,7 @@
local handlers = {} local handlers = {}
-- Module references (set by init) -- Module references (set by init)
local config, gate, mon, utils, display, events local config, gate, mon, utils, display, events, transceiver
-- State variables -- State variables
local state = { local state = {
@ -23,13 +23,14 @@ local state = {
lastGDOMatches = false lastGDOMatches = false
} }
function handlers.init(cfg, gateInterface, monitor, utilsModule, displayModule, eventsModule) function handlers.init(cfg, gateInterface, monitor, utilsModule, displayModule, eventsModule, transceiverPeripheral)
config = cfg config = cfg
gate = gateInterface gate = gateInterface
mon = monitor mon = monitor
utils = utilsModule utils = utilsModule
display = displayModule display = displayModule
events = eventsModule events = eventsModule
transceiver = transceiverPeripheral
end end
function handlers.getState() function handlers.getState()
@ -58,7 +59,37 @@ function handlers.handlePasswordInput()
-- Wait for password submission - handle events directly without the event system -- Wait for password submission - handle events directly without the event system
while state.enteringPassword do while state.enteringPassword do
local _, _, x, y = os.pullEvent("monitor_touch") -- Check if iris has opened (via GDO or other means)
if config.irisEnabled and transceiver then
local remoteIrisState = transceiver.checkConnectedShielding()
if not remoteIrisState or remoteIrisState == 0 then
-- Iris opened! Exit password prompt
utils.log("Remote iris opened, canceling password prompt")
state.enteringPassword = false
return "IRIS_OPENED"
end
end
-- Wait for event with timeout
local event = { os.pullEvent() }
local eventType = event[1]
-- Handle GDO events
if eventType == "transceiver_transmission_received" then
-- Pass to GDO handler
handlers.handleGDOTransmission(table.unpack(event))
-- Continue loop to check iris state
elseif eventType == "stargate_message_received" then
-- Pass to message handler
handlers.handleMessage(table.unpack(event))
-- Check if iris opened
if state.lastReceivedMessage == "IRIS_OPEN" then
state.lastReceivedMessage = nil
state.enteringPassword = false
return "IRIS_OPENED"
end
elseif eventType == "monitor_touch" then
local x, y = event[3], event[4]
-- Check number buttons (1-9) -- Check number buttons (1-9)
if y >= 7 and y <= 15 then if y >= 7 and y <= 15 then
@ -90,13 +121,17 @@ function handlers.handlePasswordInput()
end end
end end
end end
end
-- Send password attempt -- If we got here with a password, send it
if password ~= "" then
utils.sendPasswordAttempt(password) utils.sendPasswordAttempt(password)
return password return password
end end
return nil
end
--------------------------------------------- ---------------------------------------------
-- IRIS STATUS CLICK HANDLER (Toggle) -- IRIS STATUS CLICK HANDLER (Toggle)
--------------------------------------------- ---------------------------------------------

View File

@ -146,7 +146,7 @@ end
-- Initialize modules -- Initialize modules
utils.init(config, gate, chatBox) utils.init(config, gate, chatBox)
display.init(mon, config, addresses, utils, localGateAddress) display.init(mon, config, addresses, utils, localGateAddress)
handlers.init(config, gate, mon, utils, display, events) handlers.init(config, gate, mon, utils, display, events, transceiver)
-- Configure transceiver IDC after utils is initialized (so we can use utils.log) -- Configure transceiver IDC after utils is initialized (so we can use utils.log)
if transceiver and config.enableGDO and config.irisPassword then if transceiver and config.enableGDO and config.irisPassword then
@ -591,14 +591,14 @@ local function dialGate(address)
if (symbol) ~= 0 then if (symbol) ~= 0 then
if (gateType == "sgjourney:universe_stargate") or (gateType == "sgjourney:pegasus_stargate") then if (gateType == "sgjourney:universe_stargate") or (gateType == "sgjourney:pegasus_stargate") then
os.pullEvent("stargate_chevron_engaged") events.pullEvent("stargate_chevron_engaged")
end end
else else
if gateType == "sgjourney:universe_stargate" then if gateType == "sgjourney:universe_stargate" then
os.pullEvent("stargate_chevron_engaged") events.pullEvent("stargate_chevron_engaged")
redstone.setOutput("top", true) redstone.setOutput("top", true)
elseif (gateType == "sgjourney:pegasus_stargate") then elseif (gateType == "sgjourney:pegasus_stargate") then
os.pullEvent("stargate_chevron_engaged") events.pullEvent("stargate_chevron_engaged")
end end
end end
end end
@ -798,9 +798,15 @@ local function handleOutgoingDial()
if state.remotePasswordRequired and remoteIrisState == 100 then if state.remotePasswordRequired and remoteIrisState == 100 then
utils.log("Showing password prompt for remote gate") utils.log("Showing password prompt for remote gate")
local password = HandlePasswordEntry() local result = HandlePasswordEntry()
utils.sendPasswordAttempt(password)
utils.debug("Sent: IRIS_PASSWORD:" .. password) -- Check if iris opened during password entry (via GDO)
if result == "IRIS_OPENED" then
utils.log("Iris opened during password entry")
connectionSafe = true
elseif result then
-- Password was entered, send it
utils.debug("Sent: IRIS_PASSWORD:" .. result)
-- Wait for response -- Wait for response
local function WaitForResponse() local function WaitForResponse()
@ -808,21 +814,15 @@ local function handleOutgoingDial()
return nil return nil
end end
local result = parallel.waitForAny(GetMessage, WaitForResponse) local waitResult = parallel.waitForAny(GetMessage, WaitForResponse)
if result == 1 then if waitResult == 1 then
local response = state.lastReceivedMessage local response = state.lastReceivedMessage
state.lastReceivedMessage = nil state.lastReceivedMessage = nil
if response == "IRIS_OPEN" then if response == "IRIS_OPEN" then
display.showPasswordResult(true) display.showPasswordResult(true)
utils.log("Password accepted - iris opened") utils.log("Password accepted - iris opened")
sleep(1) sleep(1)
-- Re-check iris state
if transceiver then
remoteIrisState = transceiver.checkConnectedShielding()
end
if not remoteIrisState or remoteIrisState == 0 then
connectionSafe = true connectionSafe = true
end
elseif response == "IRIS_DENIED" then elseif response == "IRIS_DENIED" then
display.showPasswordResult(false) display.showPasswordResult(false)
utils.log("Password rejected") utils.log("Password rejected")
@ -831,6 +831,15 @@ local function handleOutgoingDial()
end end
end end
-- Re-check iris state
if transceiver then
remoteIrisState = transceiver.checkConnectedShielding()
if not remoteIrisState or remoteIrisState == 0 then
connectionSafe = true
end
end
end
-- Show warning screen if iris still closed -- Show warning screen if iris still closed
if not connectionSafe and remoteIrisState and remoteIrisState > 0 then if not connectionSafe and remoteIrisState and remoteIrisState > 0 then
mon.setBackgroundColor(colors.red) mon.setBackgroundColor(colors.red)