From 72c242d0a925cca1b76914dfa3b46a41c273578d Mon Sep 17 00:00:00 2001 From: osmarks Date: Fri, 21 Jun 2024 12:37:10 +0100 Subject: [PATCH] Lua tweaks --- computercraft/draconic_reactor.lua | 9 +++- computercraft/gcts_v2.lua | 66 ++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 computercraft/gcts_v2.lua diff --git a/computercraft/draconic_reactor.lua b/computercraft/draconic_reactor.lua index da61d47..9640b41 100644 --- a/computercraft/draconic_reactor.lua +++ b/computercraft/draconic_reactor.lua @@ -77,7 +77,12 @@ local function display_stats() if reactor_state.status == "warming_up" then status = "Reactor Precharge" status_col = colors.blue - elseif reactor_state.status ~= "cold" and (reactor_state.status == "stopping" or reactor_state.temperature > 8000 or reactor_state.fieldStrength / reactor_state.maxFieldStrength < 0.2 or reactor_state.fuelConversion / reactor_state.maxFuelConversion > 0.83) then + elseif reactor_state.status == "stopping" or reactor_state.status == "cooling" then + status = "Shutdown Running" + status_col = colors.lime + re_out_gate.setFlowOverride(1e4) + re_in_gate.setFlowOverride(0) + elseif reactor_state.status ~= "cold" and (reactor_state.temperature > 8000 or reactor_state.fieldStrength / reactor_state.maxFieldStrength < 0.2 or reactor_state.fuelConversion / reactor_state.maxFuelConversion > 0.83) then status = "Emergency Shutdown" status_col = colors.orange reactor.stopReactor() @@ -121,4 +126,4 @@ local function display_stats() end end -display_stats() \ No newline at end of file +display_stats() diff --git a/computercraft/gcts_v2.lua b/computercraft/gcts_v2.lua new file mode 100644 index 0000000..9343a02 --- /dev/null +++ b/computercraft/gcts_v2.lua @@ -0,0 +1,66 @@ +local integrators = {peripheral.find "redstone_integrator"} +local mon = peripheral.find "monitor" + +local spinner = { + "|", "/", "-", "\\" +} + +local function draw_status(god, operation, color) + local r = term.redirect(mon) + term.setBackgroundColor(color) + term.clear() + term.setCursorPos(3, 2) + term.write "God Murder/" + term.setCursorPos(3, 3) + term.write "Resurrection" + term.setCursorPos(3, 4) + term.write "System" + term.setCursorPos(3, 8) + term.write "God Status:" + term.setCursorPos(3, 9) + term.write(god) + term.setCursorPos(3, 11) + if operation then + term.write(operation .. " " .. spinner[(math.floor(os.clock() * 20) % #spinner) + 1]) + end + term.redirect(r) +end + +local function set_trapdoors(state) + for _, i in pairs(integrators) do + local s = state + if s == "random" then s = math.random(0, 1) == 0 end + i.setOutput("west", s) + end +end + +local god = "DEAD" +local operation + +while true do + if operation and math.random(0, 16) == 0 then + if god == "DEAD" then + god = "ALIVE" + elseif god == "ALIVE" then + god = "DEAD" + end + operation = nil + set_trapdoors(false) + end + if not operation and math.random(0, 30) == 0 then + if god == "DEAD" then + operation = "Resurrecting" + elseif god == "ALIVE" then + operation = "Murdering" + end + end + if operation then set_trapdoors "random" end + local color = colors.black + if operation == "Resurrecting" then + color = colors.green + elseif operation == "Murdering" then + color = colors.red + end + draw_status(god, operation, color) + sleep(operation and 0 or 1) +end \ No newline at end of file