And it's fixed, but also another problem happened. Lets fix that too
This commit is contained in:
95
handlers.lua
95
handlers.lua
@ -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,43 +59,77 @@ 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 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
|
||||
-- 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
|
||||
|
||||
-- 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
|
||||
-- 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
|
||||
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
|
||||
|
||||
-- Send password attempt
|
||||
utils.sendPasswordAttempt(password)
|
||||
-- If we got here with a password, send it
|
||||
if password ~= "" then
|
||||
utils.sendPasswordAttempt(password)
|
||||
return password
|
||||
end
|
||||
|
||||
return password
|
||||
return nil
|
||||
end
|
||||
|
||||
---------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user