fixed stupid mistake x2

This commit is contained in:
2025-12-29 00:57:30 -05:00
parent a8f5c0bfda
commit e843910241

View File

@ -76,6 +76,7 @@ local destAddressname = ""
local selx, sely = 0, 0 local selx, sely = 0, 0
local y = 0 local y = 0
local lastReceivedMessage = nil local lastReceivedMessage = nil
local remoteHasComputer = false
--------------------------------------------- ---------------------------------------------
-- EVENT HANDLERS -- EVENT HANDLERS
@ -216,6 +217,38 @@ local function MonitorRemoteIris()
utils.log("ALERT: Remote iris moving: " .. remoteIrisState .. "%") utils.log("ALERT: Remote iris moving: " .. remoteIrisState .. "%")
end end
-- If remote has computer and iris just became fully closed, offer password entry
if remoteHasComputer and remoteIrisState == 100 and (not lastIrisState or lastIrisState < 100) then
utils.log("Remote iris closed but computer detected - showing password prompt")
local password = HandlePasswordEntry()
-- Wait for response
local function WaitForResponse()
sleep(3) -- Wait up to 3 seconds for response
return nil
end
local result = parallel.waitForAny(GetMessage, WaitForResponse)
if result == 1 then
local response = lastReceivedMessage
lastReceivedMessage = nil
if response == "IRIS_OPEN" then
display.showPasswordResult(true)
utils.log("Password accepted - iris opened")
-- Continue monitoring, iris state will update
elseif response == "IRIS_DENIED" then
display.showPasswordResult(false)
utils.log("Password rejected")
end
end
-- Re-check iris state after password attempt
remoteIrisState = transceiver.checkConnectedShielding()
end
-- Show warning screen if iris still closed
if remoteIrisState and remoteIrisState > 0 then
mon.setBackgroundColor(colors.red) mon.setBackgroundColor(colors.red)
mon.clear() mon.clear()
mon.setTextScale(1) mon.setTextScale(1)
@ -230,6 +263,9 @@ local function MonitorRemoteIris()
mon.setCursorPos(3, 10) mon.setCursorPos(3, 10)
mon.write("Connection unsafe") mon.write("Connection unsafe")
display.drawIrisStatus() display.drawIrisStatus()
else
display.showConnected(destAddressname, destAddress)
end
else else
-- Remote iris is open (0 or nil) -- Remote iris is open (0 or nil)
if lastIrisState and lastIrisState > 0 then if lastIrisState and lastIrisState > 0 then
@ -505,11 +541,9 @@ local function handleOutgoingDial()
os.pullEvent("stargate_outgoing_wormhole") os.pullEvent("stargate_outgoing_wormhole")
-- Wait briefly for version message from remote gate -- Wait briefly for version message from remote gate
local remoteHasComputer = false remoteHasComputer = false
local function WaitForVersion() local function WaitForVersion()
print("Began waiting")
sleep(1) -- Wait up to 1 second for version message sleep(1) -- Wait up to 1 second for version message
print("Waited long enough")
return -1 return -1
end end
@ -521,8 +555,6 @@ local function handleOutgoingDial()
remoteHasComputer = true remoteHasComputer = true
local version = message:sub(7) local version = message:sub(7)
utils.log("Remote gate has control system version " .. version) utils.log("Remote gate has control system version " .. version)
else
print(message)
end end
end end
@ -532,37 +564,6 @@ local function handleOutgoingDial()
remoteIrisState = transceiver.checkConnectedShielding() remoteIrisState = transceiver.checkConnectedShielding()
end end
-- If remote has computer + iris closed, offer password entry
if remoteHasComputer and remoteIrisState and remoteIrisState > 0 then
utils.log("Remote iris closed but computer detected - showing password prompt")
local password = HandlePasswordEntry()
-- Wait for response
local function WaitForResponse()
sleep(3) -- Wait up to 3 seconds for response
return nil
end
result = parallel.waitForAny(GetMessage, WaitForResponse)
if result == 1 then
local response = lastReceivedMessage
lastReceivedMessage = nil
if response == "IRIS_OPEN" then
display.showPasswordResult(true)
utils.log("Password accepted - iris opened")
elseif response == "IRIS_DENIED" then
display.showPasswordResult(false)
utils.log("Password rejected")
end
end
-- Re-check iris state after password attempt
if transceiver then
remoteIrisState = transceiver.checkConnectedShielding()
end
end
if remoteIrisState and remoteIrisState > 0 then if remoteIrisState and remoteIrisState > 0 then
-- Remote iris is closed (partially or fully) -- Remote iris is closed (partially or fully)
if remoteIrisState == 100 then if remoteIrisState == 100 then
@ -606,6 +607,7 @@ local function handleOutgoingDial()
display.clearButtonData() display.clearButtonData()
destAddress = {} destAddress = {}
destAddressname = "" destAddressname = ""
remoteHasComputer = false
end end
--------------------------------------------- ---------------------------------------------