From 4946f044ecfa6bb19f5fab78a73407deae04472a Mon Sep 17 00:00:00 2001 From: Moonlit Productions Date: Thu, 1 Jan 2026 23:47:11 -0500 Subject: [PATCH] Manual iris control --- display.lua | 9 ++++++++- handlers.lua | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/display.lua b/display.lua index 499950b..dde915c 100644 --- a/display.lua +++ b/display.lua @@ -54,12 +54,17 @@ function display.drawIrisStatus() local irisState = utils.getIrisState() if irisState == "OPEN" then mon.setTextColor(colors.green) + mon.write("TOGGLE IRIS: ") elseif irisState == "CLOSED" then mon.setTextColor(colors.red) + mon.write("TOGGLE IRIS ") + elseif irisState == "MOVING" then + mon.setTextColor(colors.gray) + mon.write("IRIS MOVING ") else mon.setTextColor(colors.gray) + mon.write("IRIS: " .. irisState .. " ") end - mon.write("IRIS: " .. irisState .. " ") mon.setTextColor(colors.white) if irisState == "MOVING" then sleep(0.1) @@ -194,6 +199,8 @@ function display.showIncoming(addressName, addressString, allowed, reason) mon.setCursorPos(1, 7) mon.write(addressString) end + + display.drawIrisStatus() end function display.showEntity(entityType, entityName, allowed) diff --git a/handlers.lua b/handlers.lua index 3e62902..8b63c18 100644 --- a/handlers.lua +++ b/handlers.lua @@ -98,6 +98,41 @@ function handlers.handlePasswordInput() end --------------------------------------------- +-- IRIS STATUS CLICK HANDLER (Toggle) +--------------------------------------------- + +function handlers.handleIrisToggle(eventType, side, x, y) + -- Only process if not entering password (password handler has higher priority) + if state.enteringPassword then + return nil + end + + -- Only process if iris is enabled + if not config.irisEnabled then + return nil + end + + -- Check if clicking on iris status area (bottom-left corner where "IRIS: STATUS" appears) + -- The iris status is at position (1, 19) and extends roughly 15-20 characters + if y == 19 and x >= 1 and x <= 20 then + local irisState = utils.getIrisState() + + -- Toggle based on current state + if irisState == "OPEN" then + utils.closeIris() + display.drawIrisStatus() + return "iris_closed" + elseif irisState == "CLOSED" then + utils.openIris() + display.drawIrisStatus() + return "iris_opened" + end + -- If MOVING or NO IRIS, do nothing + end + + return nil -- Not an iris status click +end --------------------------------------------- + -- DISCONNECT BUTTON HANDLER --------------------------------------------- @@ -169,6 +204,7 @@ end function handlers.handleMessage(eventType, side, message) state.lastReceivedMessage = message + utils.debug("Message Received: " .. message) return "message_received" end @@ -200,8 +236,9 @@ function handlers.setupConnectionHandlers() -- Clear any existing handlers events.clearHandlers() -- Register all handlers with their priorities + events.registerHandler("monitor_touch", handlers.handleIrisToggle, events.PRIORITY.DISCONNECT_BUTTON) -- Same priority as disconnect events.registerHandler("monitor_touch", handlers.handleDisconnectButton, events.PRIORITY.DISCONNECT_BUTTON) - events.registerHandler("monitor_touch", handlers.handleDefaultClick, events.PRIORITY.DEFAULT) -- Lowest priority - returns coordinates + events.registerHandler("monitor_touch", handlers.handleDefaultClick, events.PRIORITY.DEFAULT) -- Lowest priority - returns coordinates events.registerHandler("stargate_incoming_wormhole", handlers.handleActivation, events.PRIORITY.ACTIVATION) events.registerHandler("stargate_reconstructing_entity", handlers.handleEntityRead, events.PRIORITY.ENTITY_READ) events.registerHandler("stargate_disconnected", handlers.handleDisconnect, events.PRIORITY.DISCONNECT_CHECK)