From 1025f626b754e99d14ce4c030d955d9710c008f5 Mon Sep 17 00:00:00 2001 From: rost Date: Sat, 6 Sep 2025 22:21:41 +0200 Subject: [PATCH 1/6] PWRangler garbage impoovments --- .../hbm/disks/pwrangler/usr/bin/PWRangler.lua | 52 +++++++++++-------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/src/main/resources/assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua b/src/main/resources/assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua index 0b86935da..2fd1379f6 100644 --- a/src/main/resources/assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua +++ b/src/main/resources/assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua @@ -3,7 +3,23 @@ local event = require "event" local gpu = component.gpu local call = component.invoke -colorGradient = {0x00FF00, 0x6BEE00, 0x95DB00, 0xB0C800, 0xC5B400, 0xD79F00, 0xE68700, 0xF46900, 0xFC4700, 0xFF0000} +local function lerp(a, b, t) + return a + (b - a) * t +end + +local function gradient(startColor, endColor, steps) + local colors = {} + for i = 0, steps-1 do + local t = i / (steps-1) + local r = math.floor(lerp((startColor >> 16) & 0xFF, (endColor >> 16) & 0xFF, t)) + local g = math.floor(lerp((startColor >> 8) & 0xFF, (endColor >> 8) & 0xFF, t)) + local b = math.floor(lerp(startColor & 0xFF, endColor & 0xFF, t)) + table.insert(colors, (r << 16) | (g << 8) | b) + end + return colors +end + +colorGradient = gradient(0x00FF00, 0xFF0000, 10) coreHeatESTOP = true coolantLossESTOP = true @@ -57,13 +73,11 @@ end buttons = {} -buttons[1] = newButton(61, 6, 6, 2, 0xFFFFFF, 0xAAAAAA, function() component.proxy(pwrController).setLevel(call(pwrController, "getLevel")+1) end) -buttons[2] = newButton(68, 6, 6, 2, 0xFFFFFF, 0xAAAAAA, function() component.proxy(pwrController).setLevel(call(pwrController, "getLevel")+5) end) -buttons[3] = newButton(75, 6, 6, 2, 0xFFFFFF, 0xAAAAAA, function() component.proxy(pwrController).setLevel(call(pwrController, "getLevel")+10) end) - -buttons[4] = newButton(61, 9, 6, 2, 0xFFFFFF, 0xAAAAAA, function() component.proxy(pwrController).setLevel(call(pwrController, "getLevel")-1) end) -buttons[5] = newButton(68, 9, 6, 2, 0xFFFFFF, 0xAAAAAA, function() component.proxy(pwrController).setLevel(call(pwrController, "getLevel")-5) end) -buttons[6] = newButton(75, 9, 6, 2, 0xFFFFFF, 0xAAAAAA, function() component.proxy(pwrController).setLevel(call(pwrController, "getLevel")-10) end) +local deltas = {1,5,10} -- This is very bad. We need new buttons +for i, d in ipairs(deltas) do + buttons[i] = newButton(61+(i-1)*7, 6, 6, 2, 0xFFFFFF, 0xAAAAAA, function() component.proxy(pwrController).setLevel(call(pwrController, "getLevel")+d) end) + buttons[i+3] = newButton(61+(i-1)*7, 9, 6, 2, 0xFFFFFF, 0xAAAAAA, function() component.proxy(pwrController).setLevel(call(pwrController, "getLevel")-d) end) +end buttons[7] = newButton(82, 6, 11, 5, 0xFF0000, 0xAA0000, function() component.proxy(pwrController).setLevel(100) end) buttons[8] = newButton(94, 6, 12, 2, 0x00FF00, 0x00AA00, function() coreHeatESTOP = not coreHeatESTOP if coreHeatESTOP == true then buttons[8].colorUp = 0x00FF00 buttons[8].colorDown = 0x00AA00 else buttons[8].colorUp = 0xFF0000 buttons[8].colorDown = 0xAA0000 end end) @@ -165,11 +179,9 @@ gpu.fill(99,15,7,1,"█") --HotDelta gpu.set(66,19,"┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃") -gpu.fill(66,22,19,1,"█") -gpu.fill(66,24,19,1,"█") -gpu.fill(66,26,19,1,"█") -gpu.fill(66,28,19,1,"█") -gpu.fill(66,30,19,1,"█") +for (y=22,30,2) do + gpu.fill(66,y,19,1,"█") +end gpu.set(66,32,"┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃") gpu.setForeground(0xAAAAAA) @@ -213,11 +225,9 @@ while (runSig == true) do gpu.setBackground(0xFFFFFF) gpu.setForeground(0xFFFFFF) - gpu.fill(66,22,19,1,"█") - gpu.fill(66,24,19,1,"█") - gpu.fill(66,26,19,1,"█") - gpu.fill(66,28,19,1,"█") - gpu.fill(66,30,19,1,"█") + for (y = 22, 30, 2) do + gpu.fill(66,y,19,1,"█") + end gpu.fill(92,15,6,5,"█") gpu.fill(92,32,6,5,"█") @@ -242,8 +252,8 @@ while (runSig == true) do gpu.fill(92,32+(5-coldCoolantLevel//25600),6,coldCoolantLevel//25600, "█") gpu.setForeground(0x000000) - gpu.set(66,22,tostring(fullCoreHeat)) - gpu.set(66,24,tostring(fullHullHeat)) + gpu.set(66,22,tostring(fullCoreHeat)) -- What the heck? This is too declarative! + gpu.set(66,24,tostring(fullHullHeat)) -- Will fix that garbage later :P gpu.set(66,26,tostring(call(pwrController, "getFlux"))) gpu.set(66,28,tostring(coldCoolantLevel)) gpu.set(66,30,tostring(hotCoolantLevel)) @@ -271,4 +281,4 @@ end event.ignore("touch", buttonPress) event.ignore("drop", buttonRelease) -gpu.fill(1,1,160,160," ") \ No newline at end of file +gpu.fill(1,1,160,160," ") From 81c5bb84d3e106c805ca41c89163643314ea0a8e Mon Sep 17 00:00:00 2001 From: rost Date: Sat, 6 Sep 2025 22:35:29 +0200 Subject: [PATCH 2/6] upd --- .../hbm/disks/pwrangler/usr/bin/PWRangler.lua | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/main/resources/assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua b/src/main/resources/assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua index 2fd1379f6..d59c13250 100644 --- a/src/main/resources/assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua +++ b/src/main/resources/assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua @@ -3,23 +3,7 @@ local event = require "event" local gpu = component.gpu local call = component.invoke -local function lerp(a, b, t) - return a + (b - a) * t -end - -local function gradient(startColor, endColor, steps) - local colors = {} - for i = 0, steps-1 do - local t = i / (steps-1) - local r = math.floor(lerp((startColor >> 16) & 0xFF, (endColor >> 16) & 0xFF, t)) - local g = math.floor(lerp((startColor >> 8) & 0xFF, (endColor >> 8) & 0xFF, t)) - local b = math.floor(lerp(startColor & 0xFF, endColor & 0xFF, t)) - table.insert(colors, (r << 16) | (g << 8) | b) - end - return colors -end - -colorGradient = gradient(0x00FF00, 0xFF0000, 10) +colorGradient = {0x00FF00, 0x6BEE00, 0x95DB00, 0xB0C800, 0xC5B400, 0xD79F00, 0xE68700, 0xF46900, 0xFC4700, 0xFF0000} coreHeatESTOP = true coolantLossESTOP = true From 3ff201bf4d3864dac7d11db6f08f938e0a077ebb Mon Sep 17 00:00:00 2001 From: rost Date: Sat, 6 Sep 2025 22:40:47 +0200 Subject: [PATCH 3/6] fixes --- .../assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua b/src/main/resources/assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua index d59c13250..8d55277bd 100644 --- a/src/main/resources/assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua +++ b/src/main/resources/assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua @@ -57,7 +57,7 @@ end buttons = {} -local deltas = {1,5,10} -- This is very bad. We need new buttons +local deltas = {1,5,10} -- This is very bad. Need new buttons for i, d in ipairs(deltas) do buttons[i] = newButton(61+(i-1)*7, 6, 6, 2, 0xFFFFFF, 0xAAAAAA, function() component.proxy(pwrController).setLevel(call(pwrController, "getLevel")+d) end) buttons[i+3] = newButton(61+(i-1)*7, 9, 6, 2, 0xFFFFFF, 0xAAAAAA, function() component.proxy(pwrController).setLevel(call(pwrController, "getLevel")-d) end) @@ -163,7 +163,7 @@ gpu.fill(99,15,7,1,"█") --HotDelta gpu.set(66,19,"┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃") -for (y=22,30,2) do +for y=22,30,2 do gpu.fill(66,y,19,1,"█") end gpu.set(66,32,"┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃") @@ -209,7 +209,7 @@ while (runSig == true) do gpu.setBackground(0xFFFFFF) gpu.setForeground(0xFFFFFF) - for (y = 22, 30, 2) do + for y = 22, 30, 2 do gpu.fill(66,y,19,1,"█") end From 98cf0b002b23c23450ca07b7aff56c5bfa90deb8 Mon Sep 17 00:00:00 2001 From: rost Date: Sun, 7 Sep 2025 11:14:30 +0200 Subject: [PATCH 4/6] hot coolant ESTOP; MAX LEVEL REQUIRED --- .../hbm/disks/pwrangler/usr/bin/PWRangler.lua | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/resources/assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua b/src/main/resources/assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua index 8d55277bd..19938d78f 100644 --- a/src/main/resources/assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua +++ b/src/main/resources/assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua @@ -6,6 +6,19 @@ local call = component.invoke colorGradient = {0x00FF00, 0x6BEE00, 0x95DB00, 0xB0C800, 0xC5B400, 0xD79F00, 0xE68700, 0xF46900, 0xFC4700, 0xFF0000} coreHeatESTOP = true coolantLossESTOP = true +hotCoolantESTOP = true + +local const = {} +local mt = { + __newindex = function(t, k, v) + error(k .. " is a constant") + end +} +setmetatable(const, mt) + +local const.fullCoreHeatMAX = 9000000 +local const.coldCoolantLevelMIN = 10000 +local const.hotCoolantLevelMAX -- = what? runSig = true @@ -251,11 +264,15 @@ while (runSig == true) do gpu.setBackground(0x000000) gpu.setForeground(0xFFFFFF) - if (coreHeatESTOP == true) and (fullCoreHeat) > 9000000 then + if (coreHeatESTOP == true) and (fullCoreHeat) > const.fullCoreHeatMAX then component.proxy(pwrController).setLevel(100) end - if (coolantLossESTOP == true) and (coldCoolantLevel) < 10000 then + if (coolantLossESTOP == true) and (coldCoolantLevel) < const.coldCoolantLevelMIN then + component.proxy(pwrController).setLevel(100) + end + + if (hotCoolantESTOP == true) and (hotCoolantLevel) > const.hotCoolantLevelMAX then component.proxy(pwrController).setLevel(100) end From 675cde7321d4a31f9c9f13ad9bc410b5231072cb Mon Sep 17 00:00:00 2001 From: rost Date: Sun, 7 Sep 2025 14:51:23 +0200 Subject: [PATCH 5/6] fixes; MAX LEVEL REQUIRED --- .../hbm/disks/pwrangler/usr/bin/PWRangler.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/resources/assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua b/src/main/resources/assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua index 19938d78f..8c2853af4 100644 --- a/src/main/resources/assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua +++ b/src/main/resources/assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua @@ -9,16 +9,22 @@ coolantLossESTOP = true hotCoolantESTOP = true local const = {} +local initialized = {} local mt = { __newindex = function(t, k, v) - error(k .. " is a constant") + if not initialized[k] then + rawset(t, k, v) + initialized[k] = true + else + error(k .. " is a constant") + end end } setmetatable(const, mt) -local const.fullCoreHeatMAX = 9000000 -local const.coldCoolantLevelMIN = 10000 -local const.hotCoolantLevelMAX -- = what? +const.fullCoreHeatMAX = 9000000 +const.coldCoolantLevelMIN = 10000 +const.hotCoolantLevelMAX -- = what? runSig = true From d7f859ecab548eab1b9fbd60931bc3af0cc3c929 Mon Sep 17 00:00:00 2001 From: rost Date: Mon, 8 Sep 2025 16:03:40 +0200 Subject: [PATCH 6/6] Final commit (max level added) --- .../assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua b/src/main/resources/assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua index 8c2853af4..09fe901aa 100644 --- a/src/main/resources/assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua +++ b/src/main/resources/assets/hbm/disks/pwrangler/usr/bin/PWRangler.lua @@ -24,7 +24,7 @@ setmetatable(const, mt) const.fullCoreHeatMAX = 9000000 const.coldCoolantLevelMIN = 10000 -const.hotCoolantLevelMAX -- = what? +const.hotCoolantLevelMAX = 0.5 runSig = true @@ -242,7 +242,7 @@ while (runSig == true) do prevHotCoolantFlow = hotCoolantLevel fullCoreHeat, fullHullHeat = call(pwrController, "getHeat") - coldCoolantLevel, _, hotCoolantLevel, _ = call(pwrController, "getCoolantInfo") + coldCoolantLevel, _, hotCoolantLevel, maxHotCoolantLevel = call(pwrController, "getCoolantInfo") coldCoolantOutflow = coldCoolantLevel - prevCoolantFlow hotCoolantOutflow = hotCoolantLevel - prevHotCoolantFlow @@ -278,7 +278,7 @@ while (runSig == true) do component.proxy(pwrController).setLevel(100) end - if (hotCoolantESTOP == true) and (hotCoolantLevel) > const.hotCoolantLevelMAX then + if (hotCoolantESTOP == true) and (hotCoolantLevel) > const.hotCoolantLevelMAX * maxHotCoolantLevel then component.proxy(pwrController).setLevel(100) end