fixed stupid mistake x2
This commit is contained in:
100
startup.lua
100
startup.lua
@ -76,6 +76,7 @@ local destAddressname = ""
|
||||
local selx, sely = 0, 0
|
||||
local y = 0
|
||||
local lastReceivedMessage = nil
|
||||
local remoteHasComputer = false
|
||||
|
||||
---------------------------------------------
|
||||
-- EVENT HANDLERS
|
||||
@ -216,20 +217,55 @@ local function MonitorRemoteIris()
|
||||
utils.log("ALERT: Remote iris moving: " .. remoteIrisState .. "%")
|
||||
end
|
||||
|
||||
mon.setBackgroundColor(colors.red)
|
||||
mon.clear()
|
||||
mon.setTextScale(1)
|
||||
mon.setCursorPos(6, 5)
|
||||
mon.write("REMOTE IRIS")
|
||||
mon.setCursorPos(8, 7)
|
||||
if remoteIrisState == 100 then
|
||||
mon.write("CLOSED!")
|
||||
else
|
||||
mon.write(remoteIrisState .. "% CLOSED")
|
||||
-- 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.clear()
|
||||
mon.setTextScale(1)
|
||||
mon.setCursorPos(6, 5)
|
||||
mon.write("REMOTE IRIS")
|
||||
mon.setCursorPos(8, 7)
|
||||
if remoteIrisState == 100 then
|
||||
mon.write("CLOSED!")
|
||||
else
|
||||
mon.write(remoteIrisState .. "% CLOSED")
|
||||
end
|
||||
mon.setCursorPos(3, 10)
|
||||
mon.write("Connection unsafe")
|
||||
display.drawIrisStatus()
|
||||
else
|
||||
display.showConnected(destAddressname, destAddress)
|
||||
end
|
||||
mon.setCursorPos(3, 10)
|
||||
mon.write("Connection unsafe")
|
||||
display.drawIrisStatus()
|
||||
else
|
||||
-- Remote iris is open (0 or nil)
|
||||
if lastIrisState and lastIrisState > 0 then
|
||||
@ -505,11 +541,9 @@ local function handleOutgoingDial()
|
||||
os.pullEvent("stargate_outgoing_wormhole")
|
||||
|
||||
-- Wait briefly for version message from remote gate
|
||||
local remoteHasComputer = false
|
||||
remoteHasComputer = false
|
||||
local function WaitForVersion()
|
||||
print("Began waiting")
|
||||
sleep(1) -- Wait up to 1 second for version message
|
||||
print("Waited long enough")
|
||||
return -1
|
||||
end
|
||||
|
||||
@ -521,8 +555,6 @@ local function handleOutgoingDial()
|
||||
remoteHasComputer = true
|
||||
local version = message:sub(7)
|
||||
utils.log("Remote gate has control system version " .. version)
|
||||
else
|
||||
print(message)
|
||||
end
|
||||
end
|
||||
|
||||
@ -532,37 +564,6 @@ local function handleOutgoingDial()
|
||||
remoteIrisState = transceiver.checkConnectedShielding()
|
||||
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
|
||||
-- Remote iris is closed (partially or fully)
|
||||
if remoteIrisState == 100 then
|
||||
@ -606,6 +607,7 @@ local function handleOutgoingDial()
|
||||
display.clearButtonData()
|
||||
destAddress = {}
|
||||
destAddressname = ""
|
||||
remoteHasComputer = false
|
||||
end
|
||||
|
||||
---------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user