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 = {}
-- Module references (set by init)
local config, gate, mon, utils, display, events
local config, gate, mon, utils, display, events, transceiver
-- State variables
local state = {
@ -23,13 +23,14 @@ local state = {
lastGDOMatches = false
}
function handlers.init(cfg, gateInterface, monitor, utilsModule, displayModule, eventsModule)
function handlers.init(cfg, gateInterface, monitor, utilsModule, displayModule, eventsModule, transceiverPeripheral)
config = cfg
gate = gateInterface
mon = monitor
utils = utilsModule
display = displayModule
events = eventsModule
transceiver = transceiverPeripheral
end
function handlers.getState()
@ -58,7 +59,37 @@ function handlers.handlePasswordInput()
-- Wait for password submission - handle events directly without the event system
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)
if y >= 7 and y <= 15 then
@ -90,13 +121,17 @@ function handlers.handlePasswordInput()
end
end
end
end
-- Send password attempt
-- If we got here with a password, send it
if password ~= "" then
utils.sendPasswordAttempt(password)
return password
end
return nil
end
---------------------------------------------
-- IRIS STATUS CLICK HANDLER (Toggle)
---------------------------------------------

View File

@ -146,7 +146,7 @@ end
-- Initialize modules
utils.init(config, gate, chatBox)
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)
if transceiver and config.enableGDO and config.irisPassword then
@ -591,14 +591,14 @@ local function dialGate(address)
if (symbol) ~= 0 then
if (gateType == "sgjourney:universe_stargate") or (gateType == "sgjourney:pegasus_stargate") then
os.pullEvent("stargate_chevron_engaged")
events.pullEvent("stargate_chevron_engaged")
end
else
if gateType == "sgjourney:universe_stargate" then
os.pullEvent("stargate_chevron_engaged")
events.pullEvent("stargate_chevron_engaged")
redstone.setOutput("top", true)
elseif (gateType == "sgjourney:pegasus_stargate") then
os.pullEvent("stargate_chevron_engaged")
events.pullEvent("stargate_chevron_engaged")
end
end
end
@ -798,9 +798,15 @@ local function handleOutgoingDial()
if state.remotePasswordRequired and remoteIrisState == 100 then
utils.log("Showing password prompt for remote gate")
local password = HandlePasswordEntry()
utils.sendPasswordAttempt(password)
utils.debug("Sent: IRIS_PASSWORD:" .. password)
local result = HandlePasswordEntry()
-- 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
local function WaitForResponse()
@ -808,21 +814,15 @@ local function handleOutgoingDial()
return nil
end
local result = parallel.waitForAny(GetMessage, WaitForResponse)
if result == 1 then
local waitResult = parallel.waitForAny(GetMessage, WaitForResponse)
if waitResult == 1 then
local response = state.lastReceivedMessage
state.lastReceivedMessage = nil
if response == "IRIS_OPEN" then
display.showPasswordResult(true)
utils.log("Password accepted - iris opened")
sleep(1)
-- Re-check iris state
if transceiver then
remoteIrisState = transceiver.checkConnectedShielding()
end
if not remoteIrisState or remoteIrisState == 0 then
connectionSafe = true
end
elseif response == "IRIS_DENIED" then
display.showPasswordResult(false)
utils.log("Password rejected")
@ -831,6 +831,15 @@ local function handleOutgoingDial()
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
if not connectionSafe and remoteIrisState and remoteIrisState > 0 then
mon.setBackgroundColor(colors.red)