From 8f24345a96bf282bd762db9354d75416d6a729fb Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Sun, 15 Mar 2026 22:53:31 -0400 Subject: [PATCH] Enhance smelter monitor setup and dashboard functionality, including recipe loading and touch event handling --- inventoryManager.lua | 55 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/inventoryManager.lua b/inventoryManager.lua index 2a33dd0..27be250 100644 --- a/inventoryManager.lua +++ b/inventoryManager.lua @@ -1599,13 +1599,32 @@ local function main() end if setupMonitor() then - print("[OK] Monitor: " .. MONITOR_SIDE) + print("[OK] Monitor: " .. (monName or MONITOR_SIDE)) else print("[WARN] No monitor on " .. MONITOR_SIDE) end + if setupSmelterMonitor() then + print("[OK] Smelter monitor: " .. (smelterMonName or SMELTER_MONITOR_SIDE)) + else + print("[WARN] No smelter monitor on " .. SMELTER_MONITOR_SIDE) + end + + -- Load recipe toggles from disk + loadDisabledRecipes() + if smeltingPaused then + print("[INIT] Smelting is PAUSED (toggle on smelter monitor)") + end + local enabledCount = 0 + local totalRecipeCount = 0 + for _ in pairs(SMELTABLE) do totalRecipeCount = totalRecipeCount + 1 end + for k in pairs(SMELTABLE) do + if not disabledRecipes[k] then enabledCount = enabledCount + 1 end + end + print(string.format("[INIT] %d/%d recipes enabled", enabledCount, totalRecipeCount)) + print("") - print("Console shows log. Use the monitor to interact.") + print("Console shows log. Use the monitors to interact.") print("") -- Try loading cached inventory from disk for instant startup @@ -1691,12 +1710,14 @@ local function main() if cacheLoaded then pcall(refreshCache) needsRedraw = true + smelterNeedsRedraw = true print("[INIT] Background refresh complete. " .. #cache.itemList .. " types.") end while true do sleep(SCAN_INTERVAL) pcall(refreshCache) needsRedraw = true + smelterNeedsRedraw = true end end, @@ -1713,19 +1734,24 @@ local function main() while true do activity.smelting = true needsRedraw = true + smelterNeedsRedraw = true local ok, didWork = pcall(autoSmelt) activity.smelting = false + -- Update furnace status quickly after smelt cycle + pcall(refreshFurnaceStatus) needsRedraw = true + smelterNeedsRedraw = true -- If work was done, scan sooner to update cache if ok and didWork then pcall(refreshCache) needsRedraw = true + smelterNeedsRedraw = true end sleep(SMELT_INTERVAL) end end, - -- Task 4: Dashboard redraw (event-driven, checks every 0.1s) + -- Task 4: Inventory dashboard redraw (event-driven, checks every 0.1s) function() needsRedraw = true while true do @@ -1745,12 +1771,29 @@ local function main() end end, - -- Task 5: Touch event listener + -- Task 5: Smelter dashboard redraw + function() + smelterNeedsRedraw = true + while true do + if smelterNeedsRedraw then + smelterNeedsRedraw = false + pcall(drawSmelterDashboard) + end + sleep(0.1) + end + end, + + -- Task 6: Touch event listener (both monitors) function() while true do local event, side, x, y = os.pullEvent("monitor_touch") - print(string.format("[TOUCH] x=%d y=%d", x, y)) - handleTouch(x, y) + if smelterMonName and side == smelterMonName then + print(string.format("[SMELT-TOUCH] x=%d y=%d", x, y)) + handleSmelterTouch(x, y) + else + print(string.format("[TOUCH] x=%d y=%d", x, y)) + handleTouch(x, y) + end end end )