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 selx, sely = 0, 0
|
||||||
local y = 0
|
local y = 0
|
||||||
local lastReceivedMessage = nil
|
local lastReceivedMessage = nil
|
||||||
|
local remoteHasComputer = false
|
||||||
|
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
-- EVENT HANDLERS
|
-- EVENT HANDLERS
|
||||||
@ -216,20 +217,55 @@ local function MonitorRemoteIris()
|
|||||||
utils.log("ALERT: Remote iris moving: " .. remoteIrisState .. "%")
|
utils.log("ALERT: Remote iris moving: " .. remoteIrisState .. "%")
|
||||||
end
|
end
|
||||||
|
|
||||||
mon.setBackgroundColor(colors.red)
|
-- If remote has computer and iris just became fully closed, offer password entry
|
||||||
mon.clear()
|
if remoteHasComputer and remoteIrisState == 100 and (not lastIrisState or lastIrisState < 100) then
|
||||||
mon.setTextScale(1)
|
utils.log("Remote iris closed but computer detected - showing password prompt")
|
||||||
mon.setCursorPos(6, 5)
|
|
||||||
mon.write("REMOTE IRIS")
|
local password = HandlePasswordEntry()
|
||||||
mon.setCursorPos(8, 7)
|
|
||||||
if remoteIrisState == 100 then
|
-- Wait for response
|
||||||
mon.write("CLOSED!")
|
local function WaitForResponse()
|
||||||
else
|
sleep(3) -- Wait up to 3 seconds for response
|
||||||
mon.write(remoteIrisState .. "% CLOSED")
|
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
|
end
|
||||||
mon.setCursorPos(3, 10)
|
|
||||||
mon.write("Connection unsafe")
|
|
||||||
display.drawIrisStatus()
|
|
||||||
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
|
||||||
|
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user