Fix direct clutch output polarity

This commit is contained in:
2026-07-17 01:38:49 +02:00
parent 17ed31c60c
commit 5a24e96217
2 changed files with 15 additions and 5 deletions
+3 -1
View File
@@ -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:
+12 -4
View File
@@ -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