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,43 +59,77 @@ 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
-- Check number buttons (1-9) local remoteIrisState = transceiver.checkConnectedShielding()
if y >= 7 and y <= 15 then if not remoteIrisState or remoteIrisState == 0 then
local row = math.floor((y - 7) / 3) -- Iris opened! Exit password prompt
local col = math.floor((x - 8) / 5) utils.log("Remote iris opened, canceling password prompt")
state.enteringPassword = false
if col >= 0 and col <= 2 and row >= 0 and row <= 2 then return "IRIS_OPENED"
local num = row * 3 + col + 1
if num >= 1 and num <= 9 then
password = password .. tostring(num)
display.updatePasswordDisplay(password)
end
end end
end end
-- Check bottom row buttons -- Wait for event with timeout
if y >= 16 and y <= 18 then local event = { os.pullEvent() }
if x >= 8 and x <= 11 then local eventType = event[1]
-- Clear button
password = "" -- Handle GDO events
display.updatePasswordDisplay(password) if eventType == "transceiver_transmission_received" then
elseif x >= 13 and x <= 16 then -- Pass to GDO handler
-- Zero button handlers.handleGDOTransmission(table.unpack(event))
password = password .. "0" -- Continue loop to check iris state
display.updatePasswordDisplay(password) elseif eventType == "stargate_message_received" then
elseif x >= 18 and x <= 21 then -- Pass to message handler
-- OK button - submit password handlers.handleMessage(table.unpack(event))
-- Check if iris opened
if state.lastReceivedMessage == "IRIS_OPEN" then
state.lastReceivedMessage = nil
state.enteringPassword = false 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
local row = math.floor((y - 7) / 3)
local col = math.floor((x - 8) / 5)
if col >= 0 and col <= 2 and row >= 0 and row <= 2 then
local num = row * 3 + col + 1
if num >= 1 and num <= 9 then
password = password .. tostring(num)
display.updatePasswordDisplay(password)
end
end
end
-- Check bottom row buttons
if y >= 16 and y <= 18 then
if x >= 8 and x <= 11 then
-- Clear button
password = ""
display.updatePasswordDisplay(password)
elseif x >= 13 and x <= 16 then
-- Zero button
password = password .. "0"
display.updatePasswordDisplay(password)
elseif x >= 18 and x <= 21 then
-- OK button - submit password
state.enteringPassword = false
end
end end
end end
end end
-- Send password attempt -- If we got here with a password, send it
utils.sendPasswordAttempt(password) if password ~= "" then
utils.sendPasswordAttempt(password)
return password
end
return password return nil
end end
--------------------------------------------- ---------------------------------------------

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,35 +798,44 @@ 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)
-- Wait for response -- Check if iris opened during password entry (via GDO)
local function WaitForResponse() if result == "IRIS_OPENED" then
sleep(3) -- Wait up to 3 seconds for response utils.log("Iris opened during password entry")
return nil connectionSafe = true
elseif result then
-- Password was entered, send it
utils.debug("Sent: IRIS_PASSWORD:" .. result)
-- Wait for response
local function WaitForResponse()
sleep(3) -- Wait up to 3 seconds for response
return nil
end
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)
connectionSafe = true
elseif response == "IRIS_DENIED" then
display.showPasswordResult(false)
utils.log("Password rejected")
sleep(2)
end
end
end end
local result = parallel.waitForAny(GetMessage, WaitForResponse) -- Re-check iris state
if result == 1 then if transceiver then
local response = state.lastReceivedMessage remoteIrisState = transceiver.checkConnectedShielding()
state.lastReceivedMessage = nil if not remoteIrisState or remoteIrisState == 0 then
if response == "IRIS_OPEN" then connectionSafe = true
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")
sleep(2)
end end
end end
end end