From 4b98b92eeffaf610963d94d16e5e2e19107e5a44 Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Tue, 18 Jan 2022 21:38:57 +0100 Subject: [PATCH] Add TA5 heat exchanger for the FR --- basis/lib.lua | 66 ++++++--- basis/submenu.lua | 2 +- fusion_reactor/controller.lua | 212 +++++++++++++++++++++-------- fusion_reactor/gas_pipe.lua | 50 ++++--- fusion_reactor/generator.lua | 39 ++---- fusion_reactor/heatexchanger1.lua | 1 - fusion_reactor/heatexchanger2.lua | 149 +++++++++++--------- fusion_reactor/heatexchanger3.lua | 1 - fusion_reactor/magnet.lua | 122 +++++++++++++---- items/powder.lua | 7 + ta3_power/tiny_generator.lua | 3 +- textures/shrink.sh | 2 - textures/techage_filling4_ta3.png | Bin 429 -> 588 bytes textures/techage_filling8_ta3.png | Bin 400 -> 573 bytes textures/techage_filling_ta3.png | Bin 399 -> 515 bytes textures/techage_filling_ta4.png | Bin 167 -> 351 bytes textures/techage_plasma.png | Bin 0 -> 865 bytes textures/techage_reactor_shell.png | Bin 273 -> 497 bytes tools/repairkit.lua | 8 -- 19 files changed, 438 insertions(+), 224 deletions(-) delete mode 100755 textures/shrink.sh create mode 100644 textures/techage_plasma.png diff --git a/basis/lib.lua b/basis/lib.lua index d605784..d47f5ac 100644 --- a/basis/lib.lua +++ b/basis/lib.lua @@ -264,25 +264,6 @@ function techage.get_node_lvm(pos) return {name="ignore", param2=0} end --- --- Functions used to hide electric cable and biogas pipes --- --- Overridden method of tubelib2! -function techage.get_primary_node_param2(pos, dir) - local npos = vector.add(pos, tubelib2.Dir6dToVector[dir or 0]) - local param2 = M(npos):get_int("tl2_param2") - if param2 ~= 0 then - return param2, npos - end -end - --- Overridden method of tubelib2! -function techage.is_primary_node(pos, dir) - local npos = vector.add(pos, tubelib2.Dir6dToVector[dir or 0]) - local param2 = M(npos):get_int("tl2_param2") - return param2 ~= 0 -end - function techage.is_air_like(name) local ndef = minetest.registered_nodes[name] if ndef and ndef.buildable_to then @@ -598,3 +579,50 @@ function techage.set_expoints(player, ex_points) end end end + +------------------------------------------------------------------------------- +-- Scheduler for a table-based, cyclic call of functions +------------------------------------------------------------------------------- +local TABLE_SIZE = 256 +techage.scheduler = {} + +local function add_to_table(tbl, i, func) + while i < TABLE_SIZE do + if not tbl[i] then + tbl[i] = func + return i + 1 + end + i = i + 1 + end + return i +end + +function techage.scheduler.init(pos) + local mem = techage.get_mem(pos) + mem.sched_idx = 0 +end + +-- tFunc : (empty) table of functions +-- call_rate : (2,4,8,16,32,64 or 128) +-- offset : 0-128 +-- func : function to be called +function techage.scheduler.register(tFunc, call_rate, offset, func) + local i= 0 + while i < TABLE_SIZE do + if (i % call_rate) == offset then + i = add_to_table(tFunc, i, func) + else + i = i + 1 + end + end + return tFunc +end + +-- tFunc : table of functions +-- default : default function (optional) +-- Returns a function to be called be the callee +function techage.scheduler.get(pos, tFunc, default) + local mem = techage.get_mem(pos) + mem.sched_idx = ((mem.sched_idx or 0) + 1) % TABLE_SIZE + return tFunc[mem.sched_idx] or default or function() end +end diff --git a/basis/submenu.lua b/basis/submenu.lua index 5ee9fb2..4c248dc 100644 --- a/basis/submenu.lua +++ b/basis/submenu.lua @@ -221,7 +221,7 @@ end function techage.menu.generate_formspec(pos, ndef, form_def, player_name) local meta = minetest.get_meta(pos) - local number = techage.get_node_number(pos) + local number = techage.get_node_number(pos) or "-" local mem = techage.get_mem(pos) mem.star = ((mem.star or 0) + 1) % 2 local star = mem.star == 1 and "*" or "" diff --git a/fusion_reactor/controller.lua b/fusion_reactor/controller.lua index 651b952..e3790ba 100644 --- a/fusion_reactor/controller.lua +++ b/fusion_reactor/controller.lua @@ -19,90 +19,172 @@ local M = minetest.get_meta local S = techage.S local Cable = techage.ElectricCable +local sched = techage.scheduler local power = networks.power local control = networks.control local CYCLE_TIME = 2 -local STANDBY_TICKS = 3 -local COUNTDOWN_TICKS = 3 -local PWR_NEEDED = 4 +local STANDBY_TICKS = 0 +local COUNTDOWN_TICKS = 1 +local PWR_NEEDED = 400 +local EXPECTED_PLASMA_NUM = 56 +local EXPECTED_SHELL_NUM = 56 +local EXPECTED_MAGNET_NUM = 56 +local CALL_RATE1 = 16 -- 2s * 16 = 32s +local CALL_RATE2 = 8 -- 2s * 8 = 16s +local DESCRIPTION = S("TA5 Fusion Reactor Controller") -local function concentrate(t) - local yes = 0 - local no = 0 +local function count_trues(t) + local cnt = 0 for _,v in ipairs(t) do if v then - yes = yes + 1 - else - no = no + 1 + cnt = cnt + 1 end end - return yes .. " yes, " .. no .. " no" + return cnt end local function nucleus(t) if #t == 4 then if vector.equals(t[1], t[2]) and vector.equals(t[3], t[4]) then - return "ok" + return true end end - return "error" - + return S("Nucleus detection error") end -local Commands = { - function(pos, outdir) +local tSched = {} + +sched.register(tSched, CALL_RATE1, 0, function(pos, outdir) + local resp = control.request(pos, Cable, outdir, "con", "connect") + local cnt = count_trues(resp) + if cnt ~= EXPECTED_MAGNET_NUM then + return S("Magnet detection error\n(@1% found / 100% expected)", math.floor(cnt* 100 / EXPECTED_MAGNET_NUM)) + end + return true + end) + +sched.register(tSched, CALL_RATE1, 1, function(pos, outdir) local resp = control.request(pos, Cable, outdir, "con", "test_plasma") - return "test_plasma: " .. concentrate(resp) - end, - function(pos, outdir) + local cnt = count_trues(resp) + if cnt ~= EXPECTED_PLASMA_NUM then + return S("Tokamak shape error") + end + return true + end) + +sched.register(tSched, CALL_RATE1, 2, function(pos, outdir) local resp = control.request(pos, Cable, outdir, "con", "test_shell") - return "test_shell: " .. concentrate(resp) - end, - function(pos, outdir) - local resp = control.request(pos, Cable, outdir, "con", "test_gas") - return "test_gas: " .. concentrate(resp) - end, - function(pos, outdir) + local cnt = count_trues(resp) + if cnt ~= EXPECTED_SHELL_NUM then + return S("Shell shape error\n(@1% found / 100% expected)", math.floor(cnt* 100 / EXPECTED_SHELL_NUM)) + end + return true + end) + +sched.register(tSched, CALL_RATE1, 3, function(pos, outdir) local resp = control.request(pos, Cable, outdir, "con", "test_nucleus") - return "test_nucleus: " .. nucleus(resp) - end, - function(pos, outdir) - local resp = control.send(pos, Cable, outdir, "con", "on") - return "on " .. resp - end, - function(pos, outdir) - local resp = control.send(pos, Cable, outdir, "con", "off") - return "off " .. resp - end, - function(pos, outdir) - local resp = control.request(pos, Cable, outdir, "con", "no_gas") - return "no_gas: " .. concentrate(resp) - end, -} + return nucleus(resp) + end) + +sched.register(tSched, CALL_RATE2, 4, function(pos, outdir) + local resp = control.request(pos, Cable, outdir, "con", "inc_power") + local cnt = count_trues(resp) + print("inc_power", cnt) + if cnt < 52 then + return S("Cooling failed") + end + return true + end) + +-- function(pos, outdir) +-- local resp = control.request(pos, Cable, outdir, "con", "no_gas") +-- return "no_gas: " .. concentrate(resp) +-- end, + +local function can_start(pos, nvm) + local outdir = networks.side_to_outdir(pos, "L") + if not power.power_available(pos, Cable, outdir) then + return S("No power") + end + outdir = networks.side_to_outdir(pos, "R") + control.request(pos, Cable, outdir, "con", "rst_power") + for i = 0,4 do + local res = tSched[i](pos, outdir) + if res ~= true then return res end + end + return true +end + +local function start_node(pos, nvm) + sched.init(pos) + local outdir = networks.side_to_outdir(pos, "R") + control.send(pos, Cable, outdir, "con", "on") + sched.init(pos) +end + +local function stop_node(pos, nvm) + local outdir = networks.side_to_outdir(pos, "R") + control.send(pos, Cable, outdir, "con", "off") +end + +local function formspec(self, pos, nvm) + return "size[5,3]".. + "box[0,-0.1;4.8,0.5;#c6e8ff]" .. + "label[0.2,-0.1;" .. minetest.colorize( "#000000", DESCRIPTION) .. "]" .. + "image_button[2,1.5;1,1;".. self:get_state_button_image(nvm) ..";state_button;]".. + "tooltip[2,1.5;1,1;"..self:get_state_tooltip(nvm).."]" +end + +local State = techage.NodeStates:new({ + node_name_passive = "techage:ta5_fr_controller_pas", + node_name_active = "techage:ta5_fr_controller_act", + cycle_time = CYCLE_TIME, + infotext_name = DESCRIPTION, + standby_ticks = STANDBY_TICKS, + can_start = can_start, + start_node = start_node, + stop_node = stop_node, + formspec_func = formspec, +}) local function after_place_node(pos, placer, itemstack) local nvm = techage.get_nvm(pos) local meta = M(pos) local own_num = techage.add_node(pos, "techage:ta5_fr_controller_pas") - meta:set_string("node_number", own_num) + State:node_init(pos, nvm, own_num) meta:set_string("owner", placer:get_player_name()) - meta:set_string("infotext", S("TA5 Fusion Reactor Controller") .. " " .. own_num) - minetest.get_node_timer(pos):start(CYCLE_TIME) Cable:after_place_node(pos) end +local function consume_power(pos, nvm, outdir) + if techage.needs_power(nvm) then + local taken = power.consume_power(pos, Cable, outdir, PWR_NEEDED) + if techage.is_running(nvm) then + if taken < PWR_NEEDED then + State:nopower(pos, nvm, "No power") + stop_node(pos, nvm) + else + return true -- keep running + end + end + end +end + local function node_timer(pos) local nvm = techage.get_nvm(pos) local outdir = networks.side_to_outdir(pos, "L") - nvm.consumed = power.consume_power(pos, Cable, outdir, 1) - - local mem = techage.get_mem(pos) - mem.idx = ((mem.idx or 0) % #Commands) + 1 - outdir = networks.Flip[outdir] - local res = Commands[mem.idx](pos, outdir) - print(res) - return true + if consume_power(pos, nvm, outdir) then + local resp = sched.get(pos, tSched, function() + return true end)(pos, networks.Flip[outdir]) + if resp ~= true then + State:fault(pos, nvm, resp) + stop_node(pos, nvm) + else + State:keep_running(pos, nvm, COUNTDOWN_TICKS) + end + end + return State:is_active(nvm) end local function after_dig_node(pos, oldnode, oldmetadata) @@ -111,6 +193,16 @@ local function after_dig_node(pos, oldnode, oldmetadata) techage.del_mem(pos) end +local function on_receive_fields(pos, formname, fields, player) + if minetest.is_protected(pos, player:get_player_name()) then + return + end + + local nvm = techage.get_nvm(pos) + State:state_button_event(pos, nvm, fields) + --M(pos):set_string("formspec", formspec(State, pos, nvm)) +end + minetest.register_node("techage:ta5_fr_controller_pas", { description = S("TA5 Fusion Reactor Controller"), tiles = { @@ -119,12 +211,13 @@ minetest.register_node("techage:ta5_fr_controller_pas", { "techage_filling_ta4.png^techage_frame_ta4_bottom.png", "techage_filling_ta4.png^techage_frame_ta5.png^techage_appl_hole_electric.png", "techage_filling_ta4.png^techage_frame_ta5.png^techage_appl_hole_electric.png", - "techage_filling_ta4.png^techage_frame_ta5.png", + "techage_filling_ta4.png^techage_appl_plasma.png^techage_frame_ta5.png", "techage_filling_ta4.png^techage_appl_plasma.png^techage_frame_ta5.png", }, after_place_node = after_place_node, on_timer = node_timer, after_dig_node = after_dig_node, + on_receive_fields = on_receive_fields, drawtype = "nodebox", paramtype2 = "facedir", groups = {choppy=2, cracky=2, crumbly=2}, @@ -140,7 +233,16 @@ minetest.register_node("techage:ta5_fr_controller_act", { "techage_filling_ta4.png^techage_frame_ta4_bottom.png", "techage_filling_ta4.png^techage_frame_ta5.png^techage_appl_hole_electric.png", "techage_filling_ta4.png^techage_frame_ta5.png^techage_appl_hole_electric.png", - "techage_filling_ta4.png^techage_frame_ta5.png", + { + image = "techage_filling4_ta4.png^techage_appl_plasma4.png^techage_frame4_ta5.png", + backface_culling = false, + animation = { + type = "vertical_frames", + aspect_w = 64, + aspect_h = 64, + length = 0.5, + }, + }, { image = "techage_filling4_ta4.png^techage_appl_plasma4.png^techage_frame4_ta5.png", backface_culling = false, @@ -155,9 +257,11 @@ minetest.register_node("techage:ta5_fr_controller_act", { after_place_node = after_place_node, on_timer = node_timer, after_dig_node = after_dig_node, + on_receive_fields = on_receive_fields, drawtype = "nodebox", paramtype2 = "facedir", - groups = {choppy=2, cracky=2, crumbly=2}, + groups = {choppy=2, cracky=2, crumbly=2, not_in_creative_inventory=1}, + drop = "", is_ground_content = false, sounds = default.node_sound_metal_defaults(), }) diff --git a/fusion_reactor/gas_pipe.lua b/fusion_reactor/gas_pipe.lua index 9f681e0..d698750 100644 --- a/fusion_reactor/gas_pipe.lua +++ b/fusion_reactor/gas_pipe.lua @@ -292,22 +292,40 @@ local names2 = networks.register_junction("techage:ta5_junctionpipe2", 1/8, Boxe liquid.register_nodes(names1, Pipe, "junc") liquid.register_nodes(names2, Pipe, "junc") ---minetest.register_craft({ --- output = "techage:ta3_junctionpipe25 2", --- recipe = { --- {"", "techage:ta3_pipeS", ""}, --- {"techage:ta3_pipeS", "", "techage:ta3_pipeS"}, --- {"", "techage:ta3_pipeS", ""}, --- }, ---}) +minetest.register_craft({ + output = "techage:ta5_pipe1S 6", + recipe = { + {'', '', "default:steel_ingot"}, + {'', 'dye:blue', 'techage:ta4_carbon_fiber'}, + {"", '', 'techage:aluminum'}, + }, +}) ---minetest.register_craft({ --- output = "techage:ta3_pipeS 6", --- recipe = { --- {'', '', "techage:iron_ingot"}, --- {'dye:yellow', 'default:steel_ingot', ''}, --- {"techage:iron_ingot", '', ''}, --- }, ---}) +minetest.register_craft({ + output = "techage:ta5_pipe2S 6", + recipe = { + {'', '', "default:steel_ingot"}, + {'', 'dye:green', 'techage:ta4_carbon_fiber'}, + {"", '', 'techage:aluminum'}, + }, +}) + +minetest.register_craft({ + output = "techage:ta5_junctionpipe125 2", + recipe = { + {"", "techage:ta5_pipe1S", ""}, + {"techage:ta5_pipe1S", "", "techage:ta5_pipe1S"}, + {"", "techage:ta5_pipe1S", ""}, + }, +}) + +minetest.register_craft({ + output = "techage:ta5_junctionpipe225 2", + recipe = { + {"", "techage:ta5_pipe2S", ""}, + {"techage:ta5_pipe2S", "", "techage:ta5_pipe2S"}, + {"", "techage:ta5_pipe2S", ""}, + }, +}) techage.GasPipe = Pipe diff --git a/fusion_reactor/generator.lua b/fusion_reactor/generator.lua index 4059465..fa21c49 100644 --- a/fusion_reactor/generator.lua +++ b/fusion_reactor/generator.lua @@ -19,8 +19,6 @@ local Cable = techage.ElectricCable local power = networks.power local CYCLE_TIME = 2 -local STANDBY_TICKS = 1 -local COUNTDOWN_TICKS = 2 local PWR_PERF = 800 local function swap_node(pos, name) @@ -41,57 +39,42 @@ local function start_node(pos, nvm) power.start_storage_calc(pos, Cable, outdir) swap_node(pos, "techage:ta5_generator_on") minetest.get_node_timer(pos):start(CYCLE_TIME) - --play_sound(pos) end local function stop_node(pos, nvm) nvm.provided = 0 + nvm.alive_cnt = 0 local outdir = M(pos):get_int("outdir") - --stop_sound(pos) power.start_storage_calc(pos, Cable, outdir) swap_node(pos, "techage:ta5_generator") end -local function on_receive_fields(pos, formname, fields, player) - if minetest.is_protected(pos, player:get_player_name()) then - return - end - local nvm = techage.get_nvm(pos) - State:state_button_event(pos, nvm, fields) -end - -local function on_rightclick(pos, node, clicker) - local nvm = techage.get_nvm(pos) - --techage.set_activeformspec(pos, clicker) - --M(pos):set_string("formspec", formspec(State, pos, nvm)) -end - local function get_generator_data(pos, outdir, tlib2) local nvm = techage.get_nvm(pos) - --if nvm.running and techage.is_running(nvm) then + if (nvm.alive_cnt or 0) > 0 then return {level = (nvm.load or 0) / PWR_PERF, perf = PWR_PERF, capa = PWR_PERF * 2} - --end + end end local function node_timer(pos, elapsed) local nvm = techage.get_nvm(pos) nvm.alive_cnt = (nvm.alive_cnt or 0) - 1 - print("node_timer", nvm.alive_cnt) if nvm.alive_cnt > 0 then local meta = M(pos) local outdir = meta:get_int("outdir") local tp1 = tonumber(meta:get_string("termpoint1")) local tp2 = tonumber(meta:get_string("termpoint2")) nvm.provided = power.provide_power(pos, Cable, outdir, PWR_PERF, tp1, tp2) - print("nvm.provided", nvm.provided) local val = power.get_storage_load(pos, Cable, outdir, PWR_PERF) if val > 0 then nvm.load = val end + return true else swap_node(pos, "techage:ta5_generator") + stop_node(pos, nvm) + return false end - return true end minetest.register_node("techage:ta5_generator", { @@ -106,7 +89,7 @@ minetest.register_node("techage:ta5_generator", { "techage_filling_ta4.png^techage_frame_ta5.png^techage_appl_generator.png^[transformFX]", }, - after_place_node = function(pos) + after_place_node = function(pos, placer) M(pos):set_int("outdir", networks.side_to_outdir(pos, "R")) Cable:after_place_node(pos) end, @@ -116,9 +99,7 @@ minetest.register_node("techage:ta5_generator", { end, get_generator_data = get_generator_data, - ta3_formspec = techage.generator_settings("ta3", PWR_PERF), - --on_receive_fields = on_receive_fields, - --on_rightclick = on_rightclick, + ta4_formspec = techage.generator_settings("ta4", PWR_PERF), paramtype2 = "facedir", groups = {cracky=2, crumbly=2, choppy=2}, on_rotate = screwdriver.disallow, @@ -157,9 +138,7 @@ minetest.register_node("techage:ta5_generator_on", { }, get_generator_data = get_generator_data, - ta3_formspec = techage.generator_settings("ta3", PWR_PERF), - --on_receive_fields = on_receive_fields, - --on_rightclick = on_rightclick, + ta4_formspec = techage.generator_settings("ta4", PWR_PERF), on_timer = node_timer, paramtype2 = "facedir", drop = "", diff --git a/fusion_reactor/heatexchanger1.lua b/fusion_reactor/heatexchanger1.lua index c6ca697..aacd3c4 100644 --- a/fusion_reactor/heatexchanger1.lua +++ b/fusion_reactor/heatexchanger1.lua @@ -34,7 +34,6 @@ end -- Send to the magnets local function control_cmnd(pos, topic) local outdir = networks.side_to_outdir(pos, "L") - print("control_cmnd1", outdir, "tank", topic) return control.request(pos, Pipe3, outdir, "tank", topic) end diff --git a/fusion_reactor/heatexchanger2.lua b/fusion_reactor/heatexchanger2.lua index 976f0f7..63f9065 100644 --- a/fusion_reactor/heatexchanger2.lua +++ b/fusion_reactor/heatexchanger2.lua @@ -21,13 +21,17 @@ local S = techage.S local Cable = techage.ElectricCable local power = networks.power local control = networks.control +local sched = techage.scheduler local CYCLE_TIME = 2 local PWR_NEEDED = 5 +local COUNTDOWN_TICKS = 1 local DOWN = 5 -- dir local DESCRIPTION = S("TA5 Heat Exchanger") local EXPECT_BLUE = 56 local EXPECT_GREEN = 52 +local CALL_RATE1 = 16 -- 2s * 16 = 32s +local CALL_RATE2 = 8 -- 2s * 8 = 16s local function heatexchanger1_cmnd(pos, topic, payload) return techage.transfer({x = pos.x, y = pos.y - 1, z = pos.z}, @@ -73,66 +77,77 @@ local function count_trues(t) return cnt end -local CheckCommands = { - function(pos) - if not power.power_available(pos, Cable, DOWN) then - return S("No power") - end - return true - end, - function(pos) - local resp = heatexchanger1_cmnd(pos, "test_gas_blue") - local cnt = count_trues(resp) - if cnt ~= EXPECT_BLUE then - return S("Blue pipe error (@1/@2)", cnt, EXPECT_BLUE) - end - return true - end, - function(pos) - local resp = heatexchanger3_cmnd(pos, "test_gas_green") - local cnt = count_trues(resp) - if cnt ~= EXPECT_GREEN then - return S("Green pipe error (@1/@2)", cnt, EXPECT_GREEN) - end - return true - end, - function(pos) +local tSched = {} + +sched.register(tSched, CALL_RATE1, 0, function(pos) if not heatexchanger1_cmnd(pos, "turbine") then return S("Turbine error") end return true - end, - function(pos) + end) +sched.register(tSched, CALL_RATE1, 1, function(pos) if not heatexchanger3_cmnd(pos, "turbine") then return S("Cooler error") end return true - end, -} + end) +sched.register(tSched, CALL_RATE1, 2, function(pos) + local resp = heatexchanger1_cmnd(pos, "test_gas_blue") + local cnt = count_trues(resp) + if cnt ~= EXPECT_BLUE then + return S("Blue pipe connection error\n(@1 found / @2 expected)", cnt, EXPECT_BLUE) + end + return true + end) +sched.register(tSched, CALL_RATE1, 3, function(pos) + local resp = heatexchanger3_cmnd(pos, "test_gas_green") + local cnt = count_trues(resp) + if cnt ~= EXPECT_GREEN then + return S("Green pipe connection error\n(@1 found / @2 expected)", cnt, EXPECT_GREEN) + end + return true + end) +sched.register(tSched, CALL_RATE2, 4, function(pos) + local resp = heatexchanger3_cmnd(pos, "dec_power") + local cnt = count_trues(resp) + print("dec_power", cnt) + if cnt < 52 then + return 0 + end + return 1 + end) local function can_start(pos, nvm) - for _,item in ipairs(CheckCommands) do - local res = item(pos) - if res ~= true then return res end + if not power.power_available(pos, Cable, DOWN) then + return S("No power") + end + heatexchanger3_cmnd(pos, "rst_power") + for i = 0,4 do + local res = tSched[i](pos) + if res ~= true and res ~= 1 then return res end end return true end local function start_node(pos, nvm) play_sound(pos) - nvm.ticks = 0 - nvm.temperature = 20 - heatexchanger1_cmnd(pos, "start") + sched.init(pos) + nvm.temperature = nvm.temperature or 0 + local mem = techage.get_mem(pos) + local t = minetest.get_gametime() - (mem.stopped_at or 0) + nvm.temperature = math.max(nvm.temperature - math.floor(t/2), 0) + nvm.temperature = math.min(nvm.temperature, 70) end local function stop_node(pos, nvm) stop_sound(pos) - nvm.temperature = 20 heatexchanger1_cmnd(pos, "stop") + local mem = techage.get_mem(pos) + mem.stopped_at = minetest.get_gametime() end local function temp_indicator (nvm, x, y) - local temp = nvm.temperature or 20 + local temp = techage.is_running(nvm) and nvm.temperature or 0 return "image[" .. x .. "," .. y .. ";1,2;techage_form_temp_bg.png^[lowpart:" .. temp .. ":techage_form_temp_fg.png]" .. "tooltip[" .. x .. "," .. y .. ";1,2;" .. S("water temperature") .. ";#0C3D32;#FFFFFF]" @@ -147,15 +162,6 @@ local function formspec(self, pos, nvm) "tooltip[3.2,1.5;1,1;"..self:get_state_tooltip(nvm).."]" end -local function check_integrity(pos, nvm) - -- Check every 30 sec - nvm.ticks = ((nvm.ticks or 0) % 15) + 1 - if CheckCommands[nvm.ticks] then - nvm.result = CheckCommands[nvm.ticks](pos) - end - return nvm.result -end - local State = techage.NodeStates:new({ node_name_passive = "techage:ta5_heatexchanger2", cycle_time = CYCLE_TIME, @@ -167,12 +173,35 @@ local State = techage.NodeStates:new({ formspec_func = formspec, }) +local function steam_management(pos, nvm) + local resp = sched.get(pos, tSched, function() return true end)(pos) + + if resp == 0 then -- has no power + nvm.temperature = math.max(nvm.temperature - 10, 0) + elseif resp == 1 then -- has power + nvm.temperature = math.min(nvm.temperature + 10, 100) + elseif resp ~= true then + State:fault(pos, nvm, resp) + stop_node(pos, nvm) + return false + end + + if nvm.temperature == 75 then + heatexchanger1_cmnd(pos, "stop") + elseif nvm.temperature == 80 then + heatexchanger1_cmnd(pos, "start") + elseif nvm.temperature > 80 then + heatexchanger1_cmnd(pos, "trigger") + end + return true +end + local function consume_power(pos, nvm) if techage.needs_power(nvm) then local taken = power.consume_power(pos, Cable, DOWN, PWR_NEEDED) if techage.is_running(nvm) then if taken < PWR_NEEDED then - State:nopower(pos, nvm, "No power") + State:nopower(pos, nvm, S("No power")) stop_sound(pos) heatexchanger1_cmnd(pos, "stop") else @@ -182,25 +211,19 @@ local function consume_power(pos, nvm) end end -local function steam_management(pos, nvm) - nvm.temperature = nvm.temperature or 20 - nvm.temperature = math.min(nvm.temperature + 1, 100) - if nvm.temperature > 80 then - heatexchanger1_cmnd(pos, "trigger") - end -end - local function node_timer(pos, elapsed) local nvm = techage.get_nvm(pos) - nvm.temperature = nvm.temperature or 20 - consume_power(pos, nvm) - if check_integrity(pos, nvm) == true then - steam_management(pos, nvm) - else - State:fault(pos, nvm, nvm.result) - stop_node(pos, nvm) + nvm.temperature = nvm.temperature or 0 + print("node_timer", nvm.temperature) + if consume_power(pos, nvm) then + if steam_management(pos, nvm) then + State:keep_running(pos, nvm, COUNTDOWN_TICKS) + end end - return State:is_active(nvm) + if techage.is_activeformspec(pos) then + M(pos):set_string("formspec", formspec(State, pos, nvm)) + end + return State:is_active(nvm) or nvm.temperature > 0 end local function can_dig(pos, player) @@ -243,7 +266,7 @@ local function on_receive_fields(pos, formname, fields, player) local nvm = techage.get_nvm(pos) State:state_button_event(pos, nvm, fields) - M(pos):set_string("formspec", formspec(State, pos, nvm)) + --M(pos):set_string("formspec", formspec(State, pos, nvm)) end -- Middle node with the formspec from the bottom node diff --git a/fusion_reactor/heatexchanger3.lua b/fusion_reactor/heatexchanger3.lua index b0d6ad4..1c719a8 100644 --- a/fusion_reactor/heatexchanger3.lua +++ b/fusion_reactor/heatexchanger3.lua @@ -55,7 +55,6 @@ end -- Send to the magnets local function control_cmnd(pos, topic) local outdir = networks.side_to_outdir(pos, "L") - print("control_cmnd3", outdir, "tank", topic) return control.request(pos, Pipe3, outdir, "tank", topic) end diff --git a/fusion_reactor/magnet.lua b/fusion_reactor/magnet.lua index 851b594..c423ff6 100644 --- a/fusion_reactor/magnet.lua +++ b/fusion_reactor/magnet.lua @@ -119,7 +119,6 @@ liquid.register_nodes({"techage:ta5_magnet1", "techage:ta5_magnet2"}, Pipe, "tan local function check_plasma(pos, param2) local pos1 = networks.get_relpos(pos, "F", param2) local node = minetest.get_node(pos1) or {} - --techage.mark_position("singleplayer", pos1, "pos1", nil, 2) return node.name == "air" end @@ -157,36 +156,61 @@ local function on_receive(pos, tlib2, topic, payload) end end +local function rst_power(nvm) + nvm.power = 0 + return true +end + +local function inc_power(nvm) + nvm.power = nvm.power or 0 + if nvm.power < 0 then nvm.power = 0 end + nvm.power = nvm.power + 1 + return nvm.power <= 2 +end + +local function dec_power(nvm) + nvm.power = nvm.power or 0 + if nvm.power > 0 then nvm.power = 0 end + nvm.power = nvm.power - 1 + return nvm.power >= -2 +end + local function on_request(pos, tlib2, topic) - --print("on_request", topic) local nvm = techage.get_nvm(pos) nvm.liquid = nvm.liquid or {} nvm.liquid.amount = nvm.liquid.amount or 0 - if topic == "test_power" and tlib2 == Cable then - nvm.has_power = true - return true - elseif topic == "test_gas_blue" and tlib2 == Pipe then - -- Test if gas is available - nvm.gas_cnt = 1 - return nvm.liquid.amount == CAPACITY - elseif topic == "test_gas_green" and tlib2 == Pipe then - -- Test if gas is heated - nvm.gas_cnt = (nvm.gas_cnt or 0) - 1 - local res = nvm.gas_cnt == 0 and nvm.has_power - nvm.has_power = false - return res - elseif topic == "no_gas" then - nvm.liquid.amount = 0 - return true - elseif topic == "test_plasma" then - local node = minetest.get_node(pos) or {} - return check_plasma(pos, node.param2) - elseif topic == "test_shell" then - local node = minetest.get_node(pos) or {} - return check_shell(pos, node.param2) - elseif topic == "test_nucleus" then - local node = minetest.get_node(pos) or {} - return check_nucleus(pos, node.param2) + if tlib2 == Cable then + if topic == "connect" then + return true + elseif topic == "inc_power" then + return inc_power(nvm) + elseif topic == "test_plasma" then + local node = minetest.get_node(pos) or {} + return check_plasma(pos, node.param2) + elseif topic == "test_shell" then + local node = minetest.get_node(pos) or {} + return check_shell(pos, node.param2) + elseif topic == "test_nucleus" then + local node = minetest.get_node(pos) or {} + return check_nucleus(pos, node.param2) + elseif topic == "no_gas" then + nvm.liquid.amount = 0 + return true + end + else -- Pipe + if topic == "dec_power" then + return dec_power(nvm) + elseif topic == "test_gas_blue" then + nvm.has_gas = true + return nvm.liquid.amount == CAPACITY + elseif topic == "test_gas_green" then + local res = nvm.has_gas + nvm.has_gas = false + return res + end + end + if topic == "rst_power" then + return rst_power(nvm) end return false end @@ -196,3 +220,47 @@ control.register_nodes({"techage:ta5_magnet1", "techage:ta5_magnet2"}, { on_request = on_request, } ) + +minetest.register_craftitem("techage:ta5_magnet_blank", { + description = S("TA5 Fusion Reactor Magnet Blank"), + inventory_image = "techage_collider_magnet.png^techage_appl_hole_electric.png", +}) + +minetest.register_craftitem("techage:ta5_magnet_shield", { + description = S("TA5 Fusion Reactor Magnet Shield"), + inventory_image = "techage_steel_tiles.png", +}) + +techage.furnace.register_recipe({ + output = "techage:ta5_magnet_shield 1", + recipe = {"default:steel_ingot", "techage:usmium_powder", "techage:graphite_powder"}, + time = 2, + +}) + +minetest.register_craft({ + output = "techage:ta5_magnet_blank 2", + recipe = { + {'default:steel_ingot', 'techage:electric_cableS', 'techage:aluminum'}, + {'techage:ta5_pipe1S', 'basic_materials:gold_wire', 'techage:ta5_pipe2S'}, + {'techage:aluminum', 'dye:brown', 'default:steel_ingot'}, + }, +}) + +minetest.register_craft({ + output = "techage:ta5_magnet1", + recipe = { + {'', 'techage:ta5_magnet_shield', 'techage:ta5_magnet_blank'}, + {'', '', ''}, + {'', '', ''}, + }, +}) + +minetest.register_craft({ + output = "techage:ta5_magnet2", + recipe = { + {'', 'techage:ta5_magnet_shield', 'techage:ta5_magnet_blank'}, + {'', '', 'techage:ta5_magnet_shield'}, + {'', '', ''}, + }, +}) diff --git a/items/powder.lua b/items/powder.lua index 1ca6484..a75ab61 100644 --- a/items/powder.lua +++ b/items/powder.lua @@ -50,6 +50,12 @@ minetest.register_craftitem("techage:silver_sandstone_powder", { groups = {powder = 1}, }) +minetest.register_craftitem("techage:graphite_powder", { + description = S("Graphite Powder"), + inventory_image = "techage_powder_inv.png^[colorize:#000000:160", + groups = {powder = 1}, +}) + techage.add_grinder_recipe({input="default:acacia_bush_leaves", output="techage:leave_powder"}) techage.add_grinder_recipe({input="default:acacia_leaves", output="techage:leave_powder"}) techage.add_grinder_recipe({input="default:aspen_leaves", output="techage:leave_powder"}) @@ -62,4 +68,5 @@ techage.add_grinder_recipe({input="default:iron_lump", output="techage:iron_powd techage.add_grinder_recipe({input="default:clay", output="techage:clay_powder"}) techage.add_grinder_recipe({input="techage:aluminum", output="techage:aluminum_powder"}) techage.add_grinder_recipe({input="default:silver_sandstone", output="techage:silver_sandstone_powder"}) +techage.add_grinder_recipe({input="default:coal_lump", output="techage:graphite_powder"}) diff --git a/ta3_power/tiny_generator.lua b/ta3_power/tiny_generator.lua index 4ee931b..db82c46 100644 --- a/ta3_power/tiny_generator.lua +++ b/ta3_power/tiny_generator.lua @@ -166,7 +166,7 @@ end local function get_generator_data(pos, outdir, tlib2) local nvm = techage.get_nvm(pos) - if nvm.running and techage.is_running(nvm) then + if techage.is_running(nvm) then return {level = (nvm.load or 0) / PWR_PERF, perf = PWR_PERF, capa = PWR_PERF * 2} end end @@ -190,7 +190,6 @@ minetest.register_node("techage:tiny_generator", { after_place_node = function(pos, placer, itemstack) local nvm = techage.get_nvm(pos) local number = techage.add_node(pos, "techage:tiny_generator") - nvm.running = false nvm.burn_cycles = 0 if itemstack then local stack_meta = itemstack:get_meta() diff --git a/textures/shrink.sh b/textures/shrink.sh deleted file mode 100755 index be401b8..0000000 --- a/textures/shrink.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -pngquant --skip-if-larger --quality=70-90 --strip *.png --ext .png --force \ No newline at end of file diff --git a/textures/techage_filling4_ta3.png b/textures/techage_filling4_ta3.png index 74c33a6f6fd55a6dc3b389e5f376da3c01ce7a9c..4576f689542e4886c9d15a2e41e17a328d06903c 100644 GIT binary patch delta 563 zcmV-30?hrb1Iz@FB!4PUOjJeIqF}jnJ;jDe!GA^7npw$;Owg27%#TpSf=An+UA}rk z-KAo(YdN7v$U_(!#hb}o4PnLNBk@yDNcYpEUWMwZtLUPL|KawGQ zK?1i6vXZjzZ~*B7xWX>zDwAiN=TKigzn~(^uerU&#|Wu^LVF0QZJLFpomDSiE~d!F9H$Rv*$sJtn7e5hn{gPqQ6*ssDwfVkZd>AHI z{3iG2Qk(j_kAHRC6~g*DVM>}kUB?K= zRYl1YuU{46`w4OSDUk44)@+eh0++eh0++sFU=_zSrE0003~Nkln0=kr2Z*ETo>*l~XTqMS@d+w%|0C3fcG1@j$O=CFRv!AH%p62= zDK}<-G6T#JQ|4jb0Sq9bK)(SZ)B|3EAE8r%i~p|_4=A)BYq-;Q4Bv^;y zqt!=B7jcJDuv%h;-nLzf1J%T_LC*-y;9`j+UvSw+f@F4xgC~|H+7ohHdkzK)i()d+ z)t+!@i$YUQTYt{#Z(7=uLz*^8G~XRaK~=ULZaFQlSA%Mhh1UDKEVpX~Me$`L&$3jz zu|b+-qITa7pdhyGc6Cst0O*OyAsg5Q?cfgM)0>D^v;>Px+cwghq*{?7I!rqVVqo~Y xAM$TM;8#E9vma+a&VHQzIQwz-<7YoU0PE&FI|Ec2P7DA5002ovPDHLkV1oOFx9|V} diff --git a/textures/techage_filling8_ta3.png b/textures/techage_filling8_ta3.png index 3802a64610d4f88264a32a88ed602f7941e872ca..74739a362b75a02bbd1b9537f3a496f31cc51e18 100644 GIT binary patch delta 548 zcmV+<0^9wN1HA;0B!4GROjJe1g-ODHMb@HVzIsB*icHOqP`PwH)tXt`pk2_FR^6py zv1&M>ST4taGphgq0ntfBK~z}7?b0!8+%Oct@n_C~c9U?DIS7i$R%4>2i(7Pr+d{B% zy{(|2B^`9u7OTzwxVM)Ms zV$3{A7&8U1f&f>^(#$Ds7-PT~$+#lRWrPeJ9O}gfE^}65hbL#UI5tj0C|+` z5AYsg%|z}dYz>)xu^wPV5q^NM@)?5U8N}M{F_r;+jW84To0~WvpsbCs)}8VWU!k;| z)l%3^%;0E>6MqqHX7!n{EH?0Jil;=h9M`z%S7zYIh+7A3O+w3-EgV;Fg52Xx!%ci# zLDk_+Q_@~9NZ782fdbZ3=o3iSN-_6K m--qwR_Z{K;@O}Juef$RbVmv~2+IBAh0000;1ds!eB!2{FK}|sb0I`n?{9y$E0004VQb$4nuFf3k0000FP)t-s(Un%m zh)ceDLa=E#*`Z%*=a0hx00AFKL_t(o!|l@1jRPSJ1W=Qs0Bmgm!Bh}vfL*!&nr;lq zCAzENB>(Kk(-_QZXqs~CI_airHjT_GH`STnz^q!$u7-~-sDFTIXX6jxKMAu_*zyy^ z6DRce0Z%X+zo7nxl_16%fDDi)tXqyfLN7RvJyOo(kZBf9qLSGUJ&ZgFsF@Z_qWJ_n z>jnZSM(lE+mGI{SWCIei0S_uK=t{>WbuLIOqbui21&|=x7T}*!@dz&{4zm=dl5`C9 z#6v0F0o=wO8E#59fNwFhW27O$o&fYw$P)=?_*$)v`vFLvSR-T9f?Ifj^bKDCX2BXO z@mP>pKcOR`gnr1oA31;YL!uwikLXAABl;2jh<-#rq94(Z=tuM;`Vsy3C;j*aFsmEF TZvbi200000NkvXXu0mjfsDYw` diff --git a/textures/techage_filling_ta3.png b/textures/techage_filling_ta3.png index 0cd5219b00ca14ae40a0da800cb61d91d40c8bc3..fe5a2147167df26b535a6de0448ec3c6f88c8d58 100644 GIT binary patch delta 489 zcmV(xN|+dctOsPQqh)I zv1vG=ST1qg3)KJs0hdWcK~yNuEzmuS+b|dh@W)B~0mNmwRYlZCr=mtQnVg_a|IBF&;b8^I^-fxN<-5rjI0pa*Uc00x{xi4YKB5)Z?a z!-t@UDxu7SfNc-v3?Y`7!1s8CVJ+a&Cw}x0$3rOq{FL{7kN7^UIl!2}MR`ta!-Ife zEaCFTR4Yp3X@8iW;i3`MDq>9&;vQt&fKuY%0pEh46sXo5qDYr8U@4KRMc|vag@@z} zZOcF72bJ-Frc$;Z^hf7t35$f`8KKszCl{6Rk}{>*8tyBachCDT2voJR8fp`L|K|!1 zg=(h;A%8)b#mhg%@z<4st+8E)@N?Pa$A`56lUe)Z>|(lEzRQmXlY!Z|VrO^j^7>>E zHXtSlyY8yI?rc?w2?*W8?aiZe2pV|e@?CejojtnT7@j~%UEXznzfSL5o@FToO)bLd f+xpI0zR~nQ5ssml_*vNs00000NkvXXu0mjf1%d5~ delta 372 zcmV-)0gL{F1djudB!3l9OjJeLqF}*(MaPFqxpY3$nOMw^P^@G%#Oeaf0003sNklQOpIHB+{*l_2omCUVEItJ^T1J2r4PZYQ`Ry5!~Fl=xHxL6{}2QEiRl8g>v@Wi?XTOqcs!(^baDn$d`Y=uKx z6`Eq)b5`GJX>AXOIPGub`RTw4sHu4q{**w85?KK0aPqw2~!I#1bRFL~133;IN-Sl<*e>icUIk S%Bq$C0000*&?i)7jhD(9zDq!@ztzhE4zg0P{&iK~yNub&#PB!Y~kqPfg&KWnpqT3uZaN z3m~wFC6iO-0Z7^xUbTMX0000^sf_TK_jRfMFHG3I;IHVp#S6|NpBYA*&cxg@%6(Wne&NFocRSFn|@ahJqO& z#eYLXfsFe9|Gz?|kj)9jqg@NCJrGGdQSPCZIfT^!0MA%$dk~~BGdutQ002ovPDHLk FV1iAgJ&ynY diff --git a/textures/techage_plasma.png b/textures/techage_plasma.png new file mode 100644 index 0000000000000000000000000000000000000000..1e7cf86a9b2a9924fa9a148f82c0c1e2e0352e6f GIT binary patch literal 865 zcmV-n1D^beP)*tERClqfkeok}frc)UV`c(oHC4RVjDNCOx&5 z()VA^xF-Ve86I))qzV8400000`~&z00K5<2s~{0DeydggR0LS7!0op>1rtHH?R(=N z#0J8Ejpy{lwo~aJ^gIM_9#l3iZ@#O{TL=Yj;{DFs8WEKU*zaGBwno3b%n670dj)_A z+t&!d`CHDH0jA@blzX+@ zIbuT>(`xWy3hQ=9$8Kl8%%^raTGcJv}8>J}Lu}rA=i0BAIUr zIEn}`$w`;(#Q{Un0FLu*fV-j?1J~(5iL$8^>Oo9Ah||ItE|t^B^A=CzMm>#j8BrmH zI$CQB>FiRzo6qOb+PUY$$u#MfbL*D#{CGX%o(KT^13c;i0000000930{s91Ze*y0= r;Qa->zkv4_0DymhCshCdI7fd09c2Z&=rt_*00000NkvXXu0mjfbjWYn literal 0 HcmV?d00001 diff --git a/textures/techage_reactor_shell.png b/textures/techage_reactor_shell.png index 5298192558bc641e76bcadc5d64997ef8b11f62a..52165c9d1e35eb43258a23e6c5920e1225559b29 100644 GIT binary patch delta 483 zcmV<90UZ930`UWo7=Hu<0001iRAueZLKp{J;^x4FQ@ ztF*hm#L1DFpu)(^rmnT{6^Lm700D?eL_t(2&pnYbYaB5Ug~x0_?MX6MM?+YgPKt`f zq;auuTyL?M>nq1q;iTyY;8F19~@hI31R&kF`3#S55Ney7$0dPcAwgPRfr6&;vfc6u z8>OV=oQE+#H-B#ck?!2nEBU(sBlZe~Kp*mR?+8!}?~ADp!zw)%FioDa%Wt(uc7%tT zK=ylOIQl*Qg3V7cPUBF%Lxu1wMK|k_ES?DG1tiVuod1xWTYCku5+M&*qtq6^TxVKH zX~Ys-K^Loa@QOFCOP>fh*Hvrp)vBixc%?P4Ql(=RE7pHyFRY9gK+^>0r;?*6g8n`)rD*%1?Rk4{ Z+y9|wn@3M22Y~006*A zL_t&-(=CrX4#F@H1t(4{Q6i-D5f#TU-#UPo^B4h_p`oWC4VU2vG~qd6tI_Uw_nAlk zef53+A>m_ynV`0S-whB$b)w5q)ib)v%qX(6HA!pEQ*XAXqIp+g^XeAv$Y}q$dg`K#^(O z_={%fc*8k|YLu@~ttOKkm10S{C_HFmDVZWJlH;y=z8?1