From 661becfb45d7cd5748fa59cf36faac8a9c9f45bd Mon Sep 17 00:00:00 2001 From: Dystroyer8 Date: Fri, 17 Jul 2026 01:52:27 +0200 Subject: [PATCH] Scope Andesite display to local production data --- README.md | 13 +++--- create_andesite_display.lua | 84 +++++++------------------------------ 2 files changed, 21 insertions(+), 76 deletions(-) diff --git a/README.md b/README.md index ad998d0..108f2fe 100644 --- a/README.md +++ b/README.md @@ -64,10 +64,9 @@ Jeder Block Reader muss direkt auf den Controller-Tank seines Boiler-Multiblocks ## Andesite-Alloy-Produktion Der erste lokale Create-Produktionscontroller ueberwacht einen Zink-Nugget-Vault, einen -Andesite-Alloy-Vault und die per Clutch getrennte Maschinenwelle. Die beiden Vaults muessen +Andesite-Alloy-Vault und die per Clutch geschaltete Produktionsanlage. 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: +Computer verbunden sein. Der Redstone-Ausgang `left` steuert die Clutch ueber einen Fail-safe-Inverter: Redstone `ON` schaltet die Fackel aus und gibt die Welle frei; bei Redstone `OFF`, Programmabbruch oder Computer-Ausfall stoppt die Fackel die Welle. @@ -80,9 +79,11 @@ create_andesite_display Der Controller erkennt die Vaults anhand von `create:zinc_nugget` und `create:andesite_alloy` und speichert ihre Peripheral-Namen. Die Freigabe wird ebenfalls -gespeichert. Fehlendes Zink, ein voller Ausgang, fehlende Vault-Daten oder eine ueberlastete -Welle schalten die Maschinenwelle ab; nach Behebung wird eine weiterhin freigegebene Anlage -automatisch fortgesetzt. Fuer den automatischen Start: +gespeichert. Fehlendes Zink, ein voller Ausgang oder fehlende Vault-Daten schalten die +Produktionsanlage ab; nach Behebung wird eine weiterhin freigegebene Anlage automatisch +fortgesetzt. Globale RPM-, Kapazitaets- und Stresswerte gehoeren in den spaeteren Create- +Serverraum, da ein Stressometer immer das gesamte zusammenhaengende kinetische Netzwerk misst. +Fuer den automatischen Start: ```lua wget https://git.peli-server.de/Dystroyer8/ATM10_CC_Codes/raw/branch/main/create_andesite_startup.lua startup.lua diff --git a/create_andesite_display.lua b/create_andesite_display.lua index 7f4fc55..ff28929 100644 --- a/create_andesite_display.lua +++ b/create_andesite_display.lua @@ -2,7 +2,6 @@ -- Two Create Item Vaults are discovered by their contents and remembered. local REFRESH_SECONDS = 1 -local SENSOR_SETTLE_SECONDS = 0.15 local MIN_WIDTH = 28 local MIN_HEIGHT = 13 local CLUTCH_OUTPUT_SIDE = "left" @@ -41,14 +40,10 @@ end local requestedRunning = loadText(STATE_FILE) == "RUNNING" local devices = textutils.unserialize(loadText(DEVICE_FILE) or "") or {} local capacityCache = {} -local lastAppliedRunning = nil local function setMachineRunning(running) local level = running and OUTPUT_LEVEL_WHEN_RUNNING or not OUTPUT_LEVEL_WHEN_RUNNING redstone.setOutput(CLUTCH_OUTPUT_SIDE, level) - local changed = lastAppliedRunning ~= running - lastAppliedRunning = running - return changed end -- Fail safe while peripherals are being discovered. @@ -102,17 +97,6 @@ local function formatInteger(value) return table.concat(parts, ".") end -local function getValueIgnoringCase(data, wantedKeys) - if type(data) ~= "table" then return nil end - for key, value in pairs(data) do - local lowered = tostring(key):lower() - for _, wanted in ipairs(wantedKeys) do - if lowered == wanted:lower() then return value end - end - end - return nil -end - local function isVault(name) return peripheral.isPresent(name) and peripheral.hasType(name, "inventory") @@ -220,61 +204,24 @@ local function discoverVaults() return savedZinc or getInventory(devices.zinc), savedAlloy or getInventory(devices.alloy) end -local function discoverStressometer() - for _, name in ipairs(peripheral.getNames()) do - if peripheral.hasType(name, "block_reader") then - local ok, data = pcall(peripheral.call, name, "getBlockData") - if ok and type(data) == "table" and tonumber(getValueIgnoringCase(data, { "Speed" })) then - local network = getValueIgnoringCase(data, { "Network" }) - local speed = math.abs(tonumber(getValueIgnoringCase(data, { "Speed" })) or 0) - if type(network) == "table" then - local capacity = tonumber(getValueIgnoringCase(network, { "Capacity" })) or 0 - local usage = tonumber(getValueIgnoringCase(network, { "Stress" })) or 0 - local load = capacity > 0 and usage / capacity * 100 or 0 - return speed, capacity, usage, load - end - return speed, nil, nil, nil - end - end - end - return nil, nil, nil, nil -end - local function evaluate() local zincVault, alloyVault = discoverVaults() local zinc = countItems(zincVault, ZINC_ITEMS) local alloy = countItems(alloyVault, ALLOY_ITEMS) - local speed, capacity, usage, load = discoverStressometer() local missing = not zincVault or not alloyVault local noMaterial = zincVault and zinc <= 0 local outputFull = alloyVault and alloyVault.capacity > 0 and alloyVault.total >= alloyVault.capacity - local overstressed = capacity and usage and usage > capacity - local allowed = not missing and not noMaterial and not outputFull and not overstressed + local allowed = not missing and not noMaterial and not outputFull local effectiveRunning = requestedRunning and allowed - local outputChanged = setMachineRunning(effectiveRunning) - - -- Create updates the kinetic network after the redstone event. Without a - -- short settling period, the first frame after a touch shows the previous - -- state and therefore looks inverted. - if outputChanged then - sleep(SENSOR_SETTLE_SECONDS) - speed, capacity, usage, load = discoverStressometer() - overstressed = capacity and usage and usage > capacity - if overstressed and effectiveRunning then - effectiveRunning = false - setMachineRunning(false) - end - end + setMachineRunning(effectiveRunning) local status, color = "STOPPED", colors.red if requestedRunning then if missing then status, color = "NO VAULT DATA", colors.red elseif noMaterial then status, color = "WAITING: NO ZINC", colors.orange elseif outputFull then status, color = "STANDBY: OUTPUT FULL", colors.orange - elseif overstressed then status, color = "STOPPED: OVERSTRESSED", colors.red - elseif not speed or speed == 0 then status, color = "STARTING / NO ROTATION", colors.orange else status, color = "RUNNING", colors.lime end end @@ -283,10 +230,8 @@ local function evaluate() alloyVault = alloyVault, zinc = zinc, alloy = alloy, - speed = speed, - capacity = capacity, - usage = usage, - load = load, + noMaterial = noMaterial, + outputFull = outputFull, status = status, statusColor = color, effectiveRunning = effectiveRunning, @@ -339,21 +284,20 @@ local function render() drawInventory(4, "ALLOY", data.alloy, data.alloyVault, data.alloyVault and data.alloyVault.total >= data.alloyVault.capacity and colors.orange or colors.lime) - center(6, "MACHINE SHAFT", colors.cyan) - if data.speed ~= nil then - center(7, ("Speed: %.1f RPM"):format(data.speed), data.speed > 0 and colors.lime or colors.orange) + center(6, "LOCAL CONTROL", colors.cyan) + if not data.zincVault then + center(7, "INPUT: NO DATA", colors.red) else - center(7, "Speed: NO DATA", colors.red) + center(7, data.noMaterial and "INPUT: EMPTY" or "INPUT: READY", + data.noMaterial and colors.orange or colors.lime) end - if data.capacity then - center(8, "SU: " .. formatInteger(data.usage) .. " / " .. formatInteger(data.capacity), colors.white) - local loadText = ("Load: %.1f %%"):format(data.load):gsub("%.", ",") - center(9, loadText, data.load >= 90 and colors.red or data.load >= 70 and colors.orange or colors.lime) + if not data.alloyVault then + center(8, "OUTPUT: NO DATA", colors.red) else - center(8, "Shaft network offline", colors.gray) + center(8, data.outputFull and "OUTPUT: FULL" or "OUTPUT: SPACE", + data.outputFull and colors.orange or colors.lime) end - - center(11, data.status, data.statusColor) + center(10, data.status, data.statusColor) drawButton(height, data) center(height, "Touch = Anlage freigeben/stoppen", colors.gray) end