Add touch control for test clutch

This commit is contained in:
2026-07-16 21:24:51 +02:00
parent 2eea78980e
commit 484b6a5117
2 changed files with 57 additions and 4 deletions
+7
View File
@@ -36,6 +36,13 @@ Drehzahl, Kapazitaet, Verbrauch und Auslastung liest es aus den Netzwerkdaten de
Die Monitoraufloesung wird automatisch erkannt und die groesste passende Textskalierung gewaehlt.
Ein Boiler ohne Wasserversorgung oder angeschlossene Engine wird als IDLE angezeigt, selbst wenn
eine Campfire- oder Blaze-Burner-Waermequelle erkannt wird.
### Clutch-Teststeuerung
Die rechte Seite des Computers ist als direkter Redstone-Ausgang fuer eine Test-Clutch
konfiguriert. Der Touch-Button auf dem Advanced Monitor schaltet diesen Ausgang ohne
Invertierung zwischen `CLUTCH SIGNAL: OFF` und `CLUTCH SIGNAL: ON` um. Die Verbindung kann
direkt mit Redstone oder drahtlos ueber ein abgestimmtes Paar Create Redstone Links erfolgen.
Die Boiler-Zuordnung erfolgt nach den internen Peripheral-Namen; die drei Block Reader sollten
deshalb in der Reihenfolge Boiler 1 bis 3 an das Wired Network angeschlossen werden. Jeder Block
Reader muss auf den Controller-Tank des zugeordneten Boiler-Multiblocks zeigen.
+50 -4
View File
@@ -4,7 +4,10 @@
local EXPECTED_BOILERS = 3
local REFRESH_SECONDS = 1
local MIN_WIDTH = 38
local MIN_HEIGHT = 11
local MIN_HEIGHT = 14
local CLUTCH_OUTPUT_SIDE = "right"
local clutchButton = { x1 = 0, x2 = 0, y = 0 }
local monitor = peripheral.find("monitor")
if not monitor then
@@ -131,6 +134,32 @@ local function formatInteger(value)
return table.concat(parts, ".")
end
local function drawClutchButton(height)
local width = monitor.getSize()
local signal = redstone.getOutput(CLUTCH_OUTPUT_SIDE)
local label = signal and " CLUTCH SIGNAL: ON " or " CLUTCH SIGNAL: OFF "
local x = math.max(1, math.floor((width - #label) / 2) + 1)
local y = math.max(13, height - 1)
clutchButton.x1 = x
clutchButton.x2 = math.min(width, x + #label - 1)
clutchButton.y = y
monitor.setCursorPos(1, y)
monitor.setBackgroundColor(colors.black)
monitor.write((" "):rep(width))
monitor.setCursorPos(x, y)
monitor.setBackgroundColor(signal and colors.orange or colors.gray)
monitor.setTextColor(colors.black)
monitor.write(label)
monitor.setBackgroundColor(colors.black)
end
local function toggleClutchSignal()
local signal = redstone.getOutput(CLUTCH_OUTPUT_SIDE)
redstone.setOutput(CLUTCH_OUTPUT_SIDE, not signal)
end
local function render()
local _, height = monitor.getSize()
local boilers, networks = discoverReaders()
@@ -157,13 +186,14 @@ local function render()
center(9, "Reader auf Speed-/Stressometer", colors.orange)
end
if height >= 13 then center(height, "Nur Anzeige - keine Steuerung", colors.gray) end
drawClutchButton(height)
center(height, "Touch = Redstone umschalten", colors.gray)
monitor.setTextColor(colors.white)
monitor.setBackgroundColor(colors.black)
term.setCursorPos(1, 1)
end
while true do
local function safeRender()
local ok, reason = pcall(render)
if not ok then
monitor.setBackgroundColor(colors.black)
@@ -171,5 +201,21 @@ while true do
center(1, "ANZEIGEFEHLER", colors.red)
center(3, tostring(reason), colors.orange)
end
sleep(REFRESH_SECONDS)
end
safeRender()
local refreshTimer = os.startTimer(REFRESH_SECONDS)
while true do
local event, first, second, third = os.pullEvent()
if event == "timer" and first == refreshTimer then
safeRender()
refreshTimer = os.startTimer(REFRESH_SECONDS)
elseif event == "monitor_touch" then
local x, y = second, third
if y == clutchButton.y and x >= clutchButton.x1 and x <= clutchButton.x2 then
toggleClutchSignal()
safeRender()
end
end
end