PWRangler garbage impoovments

This commit is contained in:
rost 2025-09-06 22:21:41 +02:00
parent 13df9566a2
commit 1025f626b7

View File

@ -3,7 +3,23 @@ local event = require "event"
local gpu = component.gpu local gpu = component.gpu
local call = component.invoke 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 coreHeatESTOP = true
coolantLossESTOP = true coolantLossESTOP = true
@ -57,13 +73,11 @@ end
buttons = {} buttons = {}
buttons[1] = newButton(61, 6, 6, 2, 0xFFFFFF, 0xAAAAAA, function() component.proxy(pwrController).setLevel(call(pwrController, "getLevel")+1) end) local deltas = {1,5,10} -- This is very bad. We need new buttons
buttons[2] = newButton(68, 6, 6, 2, 0xFFFFFF, 0xAAAAAA, function() component.proxy(pwrController).setLevel(call(pwrController, "getLevel")+5) end) for i, d in ipairs(deltas) do
buttons[3] = newButton(75, 6, 6, 2, 0xFFFFFF, 0xAAAAAA, function() component.proxy(pwrController).setLevel(call(pwrController, "getLevel")+10) end) 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)
buttons[4] = newButton(61, 9, 6, 2, 0xFFFFFF, 0xAAAAAA, function() component.proxy(pwrController).setLevel(call(pwrController, "getLevel")-1) end) 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)
buttons[7] = newButton(82, 6, 11, 5, 0xFF0000, 0xAA0000, function() component.proxy(pwrController).setLevel(100) 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) 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 --HotDelta
gpu.set(66,19,"┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃") gpu.set(66,19,"┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃")
gpu.fill(66,22,19,1,"") for (y=22,30,2) do
gpu.fill(66,24,19,1,"") gpu.fill(66,y,19,1,"")
gpu.fill(66,26,19,1,"") end
gpu.fill(66,28,19,1,"")
gpu.fill(66,30,19,1,"")
gpu.set(66,32,"┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃") gpu.set(66,32,"┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃")
gpu.setForeground(0xAAAAAA) gpu.setForeground(0xAAAAAA)
@ -213,11 +225,9 @@ while (runSig == true) do
gpu.setBackground(0xFFFFFF) gpu.setBackground(0xFFFFFF)
gpu.setForeground(0xFFFFFF) gpu.setForeground(0xFFFFFF)
gpu.fill(66,22,19,1,"") for (y = 22, 30, 2) do
gpu.fill(66,24,19,1,"") gpu.fill(66,y,19,1,"")
gpu.fill(66,26,19,1,"") end
gpu.fill(66,28,19,1,"")
gpu.fill(66,30,19,1,"")
gpu.fill(92,15,6,5,"") gpu.fill(92,15,6,5,"")
gpu.fill(92,32,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.fill(92,32+(5-coldCoolantLevel//25600),6,coldCoolantLevel//25600, "")
gpu.setForeground(0x000000) gpu.setForeground(0x000000)
gpu.set(66,22,tostring(fullCoreHeat)) gpu.set(66,22,tostring(fullCoreHeat)) -- What the heck? This is too declarative!
gpu.set(66,24,tostring(fullHullHeat)) gpu.set(66,24,tostring(fullHullHeat)) -- Will fix that garbage later :P
gpu.set(66,26,tostring(call(pwrController, "getFlux"))) gpu.set(66,26,tostring(call(pwrController, "getFlux")))
gpu.set(66,28,tostring(coldCoolantLevel)) gpu.set(66,28,tostring(coldCoolantLevel))
gpu.set(66,30,tostring(hotCoolantLevel)) gpu.set(66,30,tostring(hotCoolantLevel))