Refactor monitor setup functions to use shared UI helpers

This commit is contained in:
MayaTheShy
2026-03-22 01:55:47 -04:00
parent 1dca61eece
commit 4dc06184de

View File

@@ -148,6 +148,12 @@ end
-- Crafting grid-to-slot mapping
local GRID_TO_SLOT = {1, 2, 3, 5, 6, 7, 9, 10, 11}
-------------------------------------------------
-- Shared UI helpers (drawing, zones, craft math)
-------------------------------------------------
local ui = dofile("lib/ui.lua")
-- Active alerts (populated by checkAlerts)
local activeAlerts = {}
@@ -580,49 +586,13 @@ local networkModemName = nil
local craftTurtleName = nil
local function setupMonitor()
mon = peripheral.wrap(MONITOR_SIDE)
if mon and mon.setTextScale then
monName = MONITOR_SIDE
else
mon = nil
end
if not mon then
-- Search for a monitor on the network (skip smelter side)
for _, name in ipairs(peripheral.getNames()) do
if peripheral.getType(name) == "monitor" and name ~= SMELTER_MONITOR_SIDE then
mon = peripheral.wrap(name)
monName = name
break
end
end
end
if not mon then return false end
mon.setTextScale(0.5)
mon.clear()
return true
mon, monName = ui.setupMonitor(MONITOR_SIDE, SMELTER_MONITOR_SIDE)
return mon ~= nil
end
local function setupSmelterMonitor()
smelterMon = peripheral.wrap(SMELTER_MONITOR_SIDE)
if smelterMon and smelterMon.setTextScale then
smelterMonName = SMELTER_MONITOR_SIDE
else
smelterMon = nil
end
if not smelterMon then
-- Search for a second monitor on the network
for _, name in ipairs(peripheral.getNames()) do
if peripheral.getType(name) == "monitor" and name ~= monName then
smelterMon = peripheral.wrap(name)
smelterMonName = name
break
end
end
end
if not smelterMon then return false end
smelterMon.setTextScale(0.5)
smelterMon.clear()
return true
smelterMon, smelterMonName = ui.setupSmelterMonitor(SMELTER_MONITOR_SIDE, monName)
return smelterMon ~= nil
end
-------------------------------------------------