From 5a24e962173934b4b54af22856ef9c62237f1a1b Mon Sep 17 00:00:00 2001 From: Dystroyer8 Date: Fri, 17 Jul 2026 01:38:49 +0200 Subject: [PATCH] Fix direct clutch output polarity --- README.md | 4 +++- create_andesite_display.lua | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e50eb8a..7f54726 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,9 @@ Der erste lokale Create-Produktionscontroller ueberwacht einen Zink-Nugget-Vault Andesite-Alloy-Vault und die per Clutch getrennte Maschinenwelle. Die beiden Vaults muessen jeweils direkt ueber einen aktivierten Wired Modem Full Block als Inventory-Peripheral mit dem Computer verbunden sein. Ein Advanced-Peripherals Block Reader zeigt auf das Stressometer der -Maschinenwelle. Der Redstone-Ausgang `left` steuert die Clutch ueber einen Fail-safe-Inverter. +Maschinenwelle. Der Redstone-Ausgang `left` steuert die Clutch in der aktuellen Installation +direkt: Redstone `ON` stoppt die Welle und Redstone `OFF` gibt sie frei. Die Polaritaet ist im +Programm ueber `OUTPUT_LEVEL_WHEN_RUNNING` konfigurierbar. Installation und erster Start: diff --git a/create_andesite_display.lua b/create_andesite_display.lua index 5579040..2d9cd0c 100644 --- a/create_andesite_display.lua +++ b/create_andesite_display.lua @@ -5,6 +5,9 @@ local REFRESH_SECONDS = 1 local MIN_WIDTH = 28 local MIN_HEIGHT = 13 local CLUTCH_OUTPUT_SIDE = "left" +-- This installation drives the Clutch directly: powered means stopped. +-- Change to true if a redstone-torch inverter is installed later. +local OUTPUT_LEVEL_WHEN_RUNNING = false local STATE_FILE = "create_andesite_state.txt" local DEVICE_FILE = "create_andesite_devices.txt" @@ -39,8 +42,13 @@ local requestedRunning = loadText(STATE_FILE) == "RUNNING" local devices = textutils.unserialize(loadText(DEVICE_FILE) or "") or {} local capacityCache = {} +local function setMachineRunning(running) + local level = running and OUTPUT_LEVEL_WHEN_RUNNING or not OUTPUT_LEVEL_WHEN_RUNNING + redstone.setOutput(CLUTCH_OUTPUT_SIDE, level) +end + -- Fail safe while peripherals are being discovered. -redstone.setOutput(CLUTCH_OUTPUT_SIDE, false) +setMachineRunning(false) local monitor = peripheral.find("monitor") if not monitor then @@ -241,7 +249,7 @@ local function evaluate() local allowed = not missing and not noMaterial and not outputFull and not overstressed local effectiveRunning = requestedRunning and allowed - redstone.setOutput(CLUTCH_OUTPUT_SIDE, effectiveRunning) + setMachineRunning(effectiveRunning) local status, color = "STOPPED", colors.red if requestedRunning then @@ -336,7 +344,7 @@ end local function safeRender() local ok, reason = pcall(render) if not ok then - redstone.setOutput(CLUTCH_OUTPUT_SIDE, false) + setMachineRunning(false) monitor.setBackgroundColor(colors.black) monitor.clear() center(1, "CONTROLLER ERROR", colors.red) @@ -371,5 +379,5 @@ local function run() end local ok, reason = pcall(run) -redstone.setOutput(CLUTCH_OUTPUT_SIDE, false) +setMachineRunning(false) if not ok then error(reason, 0) end