Add TA5 heat exchanger for the FR

This commit is contained in:
Joachim Stolberg 2022-01-18 21:38:57 +01:00
parent 76e83db072
commit 4b98b92eef
19 changed files with 438 additions and 224 deletions

View File

@ -264,25 +264,6 @@ function techage.get_node_lvm(pos)
return {name="ignore", param2=0} return {name="ignore", param2=0}
end 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) function techage.is_air_like(name)
local ndef = minetest.registered_nodes[name] local ndef = minetest.registered_nodes[name]
if ndef and ndef.buildable_to then if ndef and ndef.buildable_to then
@ -598,3 +579,50 @@ function techage.set_expoints(player, ex_points)
end end
end 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

View File

@ -221,7 +221,7 @@ end
function techage.menu.generate_formspec(pos, ndef, form_def, player_name) function techage.menu.generate_formspec(pos, ndef, form_def, player_name)
local meta = minetest.get_meta(pos) 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) local mem = techage.get_mem(pos)
mem.star = ((mem.star or 0) + 1) % 2 mem.star = ((mem.star or 0) + 1) % 2
local star = mem.star == 1 and "*" or "" local star = mem.star == 1 and "*" or ""

View File

@ -19,90 +19,172 @@ local M = minetest.get_meta
local S = techage.S local S = techage.S
local Cable = techage.ElectricCable local Cable = techage.ElectricCable
local sched = techage.scheduler
local power = networks.power local power = networks.power
local control = networks.control local control = networks.control
local CYCLE_TIME = 2 local CYCLE_TIME = 2
local STANDBY_TICKS = 3 local STANDBY_TICKS = 0
local COUNTDOWN_TICKS = 3 local COUNTDOWN_TICKS = 1
local PWR_NEEDED = 4 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 function count_trues(t)
local yes = 0 local cnt = 0
local no = 0
for _,v in ipairs(t) do for _,v in ipairs(t) do
if v then if v then
yes = yes + 1 cnt = cnt + 1
else
no = no + 1
end end
end end
return yes .. " yes, " .. no .. " no" return cnt
end end
local function nucleus(t) local function nucleus(t)
if #t == 4 then if #t == 4 then
if vector.equals(t[1], t[2]) and vector.equals(t[3], t[4]) then if vector.equals(t[1], t[2]) and vector.equals(t[3], t[4]) then
return "ok" return true
end end
end end
return "error" return S("Nucleus detection error")
end end
local Commands = { local tSched = {}
function(pos, outdir)
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") local resp = control.request(pos, Cable, outdir, "con", "test_plasma")
return "test_plasma: " .. concentrate(resp) local cnt = count_trues(resp)
end, if cnt ~= EXPECTED_PLASMA_NUM then
function(pos, outdir) 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") local resp = control.request(pos, Cable, outdir, "con", "test_shell")
return "test_shell: " .. concentrate(resp) local cnt = count_trues(resp)
end, if cnt ~= EXPECTED_SHELL_NUM then
function(pos, outdir) return S("Shell shape error\n(@1% found / 100% expected)", math.floor(cnt* 100 / EXPECTED_SHELL_NUM))
local resp = control.request(pos, Cable, outdir, "con", "test_gas") end
return "test_gas: " .. concentrate(resp) return true
end, end)
function(pos, outdir)
sched.register(tSched, CALL_RATE1, 3, function(pos, outdir)
local resp = control.request(pos, Cable, outdir, "con", "test_nucleus") local resp = control.request(pos, Cable, outdir, "con", "test_nucleus")
return "test_nucleus: " .. nucleus(resp) return nucleus(resp)
end, end)
function(pos, outdir)
local resp = control.send(pos, Cable, outdir, "con", "on") sched.register(tSched, CALL_RATE2, 4, function(pos, outdir)
return "on " .. resp local resp = control.request(pos, Cable, outdir, "con", "inc_power")
end, local cnt = count_trues(resp)
function(pos, outdir) print("inc_power", cnt)
local resp = control.send(pos, Cable, outdir, "con", "off") if cnt < 52 then
return "off " .. resp return S("Cooling failed")
end, end
function(pos, outdir) return true
local resp = control.request(pos, Cable, outdir, "con", "no_gas") end)
return "no_gas: " .. concentrate(resp)
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 function after_place_node(pos, placer, itemstack)
local nvm = techage.get_nvm(pos) local nvm = techage.get_nvm(pos)
local meta = M(pos) local meta = M(pos)
local own_num = techage.add_node(pos, "techage:ta5_fr_controller_pas") 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("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) Cable:after_place_node(pos)
end 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 function node_timer(pos)
local nvm = techage.get_nvm(pos) local nvm = techage.get_nvm(pos)
local outdir = networks.side_to_outdir(pos, "L") local outdir = networks.side_to_outdir(pos, "L")
nvm.consumed = power.consume_power(pos, Cable, outdir, 1) if consume_power(pos, nvm, outdir) then
local resp = sched.get(pos, tSched, function()
local mem = techage.get_mem(pos) return true end)(pos, networks.Flip[outdir])
mem.idx = ((mem.idx or 0) % #Commands) + 1 if resp ~= true then
outdir = networks.Flip[outdir] State:fault(pos, nvm, resp)
local res = Commands[mem.idx](pos, outdir) stop_node(pos, nvm)
print(res) else
return true State:keep_running(pos, nvm, COUNTDOWN_TICKS)
end
end
return State:is_active(nvm)
end end
local function after_dig_node(pos, oldnode, oldmetadata) local function after_dig_node(pos, oldnode, oldmetadata)
@ -111,6 +193,16 @@ local function after_dig_node(pos, oldnode, oldmetadata)
techage.del_mem(pos) techage.del_mem(pos)
end 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", { minetest.register_node("techage:ta5_fr_controller_pas", {
description = S("TA5 Fusion Reactor Controller"), description = S("TA5 Fusion Reactor Controller"),
tiles = { 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_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_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", "techage_filling_ta4.png^techage_appl_plasma.png^techage_frame_ta5.png",
}, },
after_place_node = after_place_node, after_place_node = after_place_node,
on_timer = node_timer, on_timer = node_timer,
after_dig_node = after_dig_node, after_dig_node = after_dig_node,
on_receive_fields = on_receive_fields,
drawtype = "nodebox", drawtype = "nodebox",
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {choppy=2, cracky=2, crumbly=2}, 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_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_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", image = "techage_filling4_ta4.png^techage_appl_plasma4.png^techage_frame4_ta5.png",
backface_culling = false, backface_culling = false,
@ -155,9 +257,11 @@ minetest.register_node("techage:ta5_fr_controller_act", {
after_place_node = after_place_node, after_place_node = after_place_node,
on_timer = node_timer, on_timer = node_timer,
after_dig_node = after_dig_node, after_dig_node = after_dig_node,
on_receive_fields = on_receive_fields,
drawtype = "nodebox", drawtype = "nodebox",
paramtype2 = "facedir", 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, is_ground_content = false,
sounds = default.node_sound_metal_defaults(), sounds = default.node_sound_metal_defaults(),
}) })

View File

@ -292,22 +292,40 @@ local names2 = networks.register_junction("techage:ta5_junctionpipe2", 1/8, Boxe
liquid.register_nodes(names1, Pipe, "junc") liquid.register_nodes(names1, Pipe, "junc")
liquid.register_nodes(names2, Pipe, "junc") liquid.register_nodes(names2, Pipe, "junc")
--minetest.register_craft({ minetest.register_craft({
-- output = "techage:ta3_junctionpipe25 2", output = "techage:ta5_pipe1S 6",
-- recipe = { recipe = {
-- {"", "techage:ta3_pipeS", ""}, {'', '', "default:steel_ingot"},
-- {"techage:ta3_pipeS", "", "techage:ta3_pipeS"}, {'', 'dye:blue', 'techage:ta4_carbon_fiber'},
-- {"", "techage:ta3_pipeS", ""}, {"", '', 'techage:aluminum'},
-- }, },
--}) })
--minetest.register_craft({ minetest.register_craft({
-- output = "techage:ta3_pipeS 6", output = "techage:ta5_pipe2S 6",
-- recipe = { recipe = {
-- {'', '', "techage:iron_ingot"}, {'', '', "default:steel_ingot"},
-- {'dye:yellow', 'default:steel_ingot', ''}, {'', 'dye:green', 'techage:ta4_carbon_fiber'},
-- {"techage:iron_ingot", '', ''}, {"", '', '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 techage.GasPipe = Pipe

View File

@ -19,8 +19,6 @@ local Cable = techage.ElectricCable
local power = networks.power local power = networks.power
local CYCLE_TIME = 2 local CYCLE_TIME = 2
local STANDBY_TICKS = 1
local COUNTDOWN_TICKS = 2
local PWR_PERF = 800 local PWR_PERF = 800
local function swap_node(pos, name) local function swap_node(pos, name)
@ -41,57 +39,42 @@ local function start_node(pos, nvm)
power.start_storage_calc(pos, Cable, outdir) power.start_storage_calc(pos, Cable, outdir)
swap_node(pos, "techage:ta5_generator_on") swap_node(pos, "techage:ta5_generator_on")
minetest.get_node_timer(pos):start(CYCLE_TIME) minetest.get_node_timer(pos):start(CYCLE_TIME)
--play_sound(pos)
end end
local function stop_node(pos, nvm) local function stop_node(pos, nvm)
nvm.provided = 0 nvm.provided = 0
nvm.alive_cnt = 0
local outdir = M(pos):get_int("outdir") local outdir = M(pos):get_int("outdir")
--stop_sound(pos)
power.start_storage_calc(pos, Cable, outdir) power.start_storage_calc(pos, Cable, outdir)
swap_node(pos, "techage:ta5_generator") swap_node(pos, "techage:ta5_generator")
end 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 function get_generator_data(pos, outdir, tlib2)
local nvm = techage.get_nvm(pos) 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} return {level = (nvm.load or 0) / PWR_PERF, perf = PWR_PERF, capa = PWR_PERF * 2}
--end end
end end
local function node_timer(pos, elapsed) local function node_timer(pos, elapsed)
local nvm = techage.get_nvm(pos) local nvm = techage.get_nvm(pos)
nvm.alive_cnt = (nvm.alive_cnt or 0) - 1 nvm.alive_cnt = (nvm.alive_cnt or 0) - 1
print("node_timer", nvm.alive_cnt)
if nvm.alive_cnt > 0 then if nvm.alive_cnt > 0 then
local meta = M(pos) local meta = M(pos)
local outdir = meta:get_int("outdir") local outdir = meta:get_int("outdir")
local tp1 = tonumber(meta:get_string("termpoint1")) local tp1 = tonumber(meta:get_string("termpoint1"))
local tp2 = tonumber(meta:get_string("termpoint2")) local tp2 = tonumber(meta:get_string("termpoint2"))
nvm.provided = power.provide_power(pos, Cable, outdir, PWR_PERF, tp1, tp2) 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) local val = power.get_storage_load(pos, Cable, outdir, PWR_PERF)
if val > 0 then if val > 0 then
nvm.load = val nvm.load = val
end end
return true
else else
swap_node(pos, "techage:ta5_generator") swap_node(pos, "techage:ta5_generator")
stop_node(pos, nvm)
return false
end end
return true
end end
minetest.register_node("techage:ta5_generator", { 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]", "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")) M(pos):set_int("outdir", networks.side_to_outdir(pos, "R"))
Cable:after_place_node(pos) Cable:after_place_node(pos)
end, end,
@ -116,9 +99,7 @@ minetest.register_node("techage:ta5_generator", {
end, end,
get_generator_data = get_generator_data, get_generator_data = get_generator_data,
ta3_formspec = techage.generator_settings("ta3", PWR_PERF), ta4_formspec = techage.generator_settings("ta4", PWR_PERF),
--on_receive_fields = on_receive_fields,
--on_rightclick = on_rightclick,
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {cracky=2, crumbly=2, choppy=2}, groups = {cracky=2, crumbly=2, choppy=2},
on_rotate = screwdriver.disallow, on_rotate = screwdriver.disallow,
@ -157,9 +138,7 @@ minetest.register_node("techage:ta5_generator_on", {
}, },
get_generator_data = get_generator_data, get_generator_data = get_generator_data,
ta3_formspec = techage.generator_settings("ta3", PWR_PERF), ta4_formspec = techage.generator_settings("ta4", PWR_PERF),
--on_receive_fields = on_receive_fields,
--on_rightclick = on_rightclick,
on_timer = node_timer, on_timer = node_timer,
paramtype2 = "facedir", paramtype2 = "facedir",
drop = "", drop = "",

View File

@ -34,7 +34,6 @@ end
-- Send to the magnets -- Send to the magnets
local function control_cmnd(pos, topic) local function control_cmnd(pos, topic)
local outdir = networks.side_to_outdir(pos, "L") local outdir = networks.side_to_outdir(pos, "L")
print("control_cmnd1", outdir, "tank", topic)
return control.request(pos, Pipe3, outdir, "tank", topic) return control.request(pos, Pipe3, outdir, "tank", topic)
end end

View File

@ -21,13 +21,17 @@ local S = techage.S
local Cable = techage.ElectricCable local Cable = techage.ElectricCable
local power = networks.power local power = networks.power
local control = networks.control local control = networks.control
local sched = techage.scheduler
local CYCLE_TIME = 2 local CYCLE_TIME = 2
local PWR_NEEDED = 5 local PWR_NEEDED = 5
local COUNTDOWN_TICKS = 1
local DOWN = 5 -- dir local DOWN = 5 -- dir
local DESCRIPTION = S("TA5 Heat Exchanger") local DESCRIPTION = S("TA5 Heat Exchanger")
local EXPECT_BLUE = 56 local EXPECT_BLUE = 56
local EXPECT_GREEN = 52 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) local function heatexchanger1_cmnd(pos, topic, payload)
return techage.transfer({x = pos.x, y = pos.y - 1, z = pos.z}, return techage.transfer({x = pos.x, y = pos.y - 1, z = pos.z},
@ -73,66 +77,77 @@ local function count_trues(t)
return cnt return cnt
end end
local CheckCommands = { local tSched = {}
function(pos)
if not power.power_available(pos, Cable, DOWN) then sched.register(tSched, CALL_RATE1, 0, function(pos)
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)
if not heatexchanger1_cmnd(pos, "turbine") then if not heatexchanger1_cmnd(pos, "turbine") then
return S("Turbine error") return S("Turbine error")
end end
return true return true
end, end)
function(pos) sched.register(tSched, CALL_RATE1, 1, function(pos)
if not heatexchanger3_cmnd(pos, "turbine") then if not heatexchanger3_cmnd(pos, "turbine") then
return S("Cooler error") return S("Cooler error")
end end
return true 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) local function can_start(pos, nvm)
for _,item in ipairs(CheckCommands) do if not power.power_available(pos, Cable, DOWN) then
local res = item(pos) return S("No power")
if res ~= true then return res end 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 end
return true return true
end end
local function start_node(pos, nvm) local function start_node(pos, nvm)
play_sound(pos) play_sound(pos)
nvm.ticks = 0 sched.init(pos)
nvm.temperature = 20 nvm.temperature = nvm.temperature or 0
heatexchanger1_cmnd(pos, "start") 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 end
local function stop_node(pos, nvm) local function stop_node(pos, nvm)
stop_sound(pos) stop_sound(pos)
nvm.temperature = 20
heatexchanger1_cmnd(pos, "stop") heatexchanger1_cmnd(pos, "stop")
local mem = techage.get_mem(pos)
mem.stopped_at = minetest.get_gametime()
end end
local function temp_indicator (nvm, x, y) 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:" .. return "image[" .. x .. "," .. y .. ";1,2;techage_form_temp_bg.png^[lowpart:" ..
temp .. ":techage_form_temp_fg.png]" .. temp .. ":techage_form_temp_fg.png]" ..
"tooltip[" .. x .. "," .. y .. ";1,2;" .. S("water temperature") .. ";#0C3D32;#FFFFFF]" "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).."]" "tooltip[3.2,1.5;1,1;"..self:get_state_tooltip(nvm).."]"
end 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({ local State = techage.NodeStates:new({
node_name_passive = "techage:ta5_heatexchanger2", node_name_passive = "techage:ta5_heatexchanger2",
cycle_time = CYCLE_TIME, cycle_time = CYCLE_TIME,
@ -167,12 +173,35 @@ local State = techage.NodeStates:new({
formspec_func = formspec, 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) local function consume_power(pos, nvm)
if techage.needs_power(nvm) then if techage.needs_power(nvm) then
local taken = power.consume_power(pos, Cable, DOWN, PWR_NEEDED) local taken = power.consume_power(pos, Cable, DOWN, PWR_NEEDED)
if techage.is_running(nvm) then if techage.is_running(nvm) then
if taken < PWR_NEEDED then if taken < PWR_NEEDED then
State:nopower(pos, nvm, "No power") State:nopower(pos, nvm, S("No power"))
stop_sound(pos) stop_sound(pos)
heatexchanger1_cmnd(pos, "stop") heatexchanger1_cmnd(pos, "stop")
else else
@ -182,25 +211,19 @@ local function consume_power(pos, nvm)
end end
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 function node_timer(pos, elapsed)
local nvm = techage.get_nvm(pos) local nvm = techage.get_nvm(pos)
nvm.temperature = nvm.temperature or 20 nvm.temperature = nvm.temperature or 0
consume_power(pos, nvm) print("node_timer", nvm.temperature)
if check_integrity(pos, nvm) == true then if consume_power(pos, nvm) then
steam_management(pos, nvm) if steam_management(pos, nvm) then
else State:keep_running(pos, nvm, COUNTDOWN_TICKS)
State:fault(pos, nvm, nvm.result)
stop_node(pos, nvm)
end end
return State:is_active(nvm) end
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 end
local function can_dig(pos, player) 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) local nvm = techage.get_nvm(pos)
State:state_button_event(pos, nvm, fields) 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 end
-- Middle node with the formspec from the bottom node -- Middle node with the formspec from the bottom node

View File

@ -55,7 +55,6 @@ end
-- Send to the magnets -- Send to the magnets
local function control_cmnd(pos, topic) local function control_cmnd(pos, topic)
local outdir = networks.side_to_outdir(pos, "L") local outdir = networks.side_to_outdir(pos, "L")
print("control_cmnd3", outdir, "tank", topic)
return control.request(pos, Pipe3, outdir, "tank", topic) return control.request(pos, Pipe3, outdir, "tank", topic)
end end

View File

@ -119,7 +119,6 @@ liquid.register_nodes({"techage:ta5_magnet1", "techage:ta5_magnet2"}, Pipe, "tan
local function check_plasma(pos, param2) local function check_plasma(pos, param2)
local pos1 = networks.get_relpos(pos, "F", param2) local pos1 = networks.get_relpos(pos, "F", param2)
local node = minetest.get_node(pos1) or {} local node = minetest.get_node(pos1) or {}
--techage.mark_position("singleplayer", pos1, "pos1", nil, 2)
return node.name == "air" return node.name == "air"
end end
@ -157,27 +156,34 @@ local function on_receive(pos, tlib2, topic, payload)
end end
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) local function on_request(pos, tlib2, topic)
--print("on_request", topic)
local nvm = techage.get_nvm(pos) local nvm = techage.get_nvm(pos)
nvm.liquid = nvm.liquid or {} nvm.liquid = nvm.liquid or {}
nvm.liquid.amount = nvm.liquid.amount or 0 nvm.liquid.amount = nvm.liquid.amount or 0
if topic == "test_power" and tlib2 == Cable then if tlib2 == Cable then
nvm.has_power = true if topic == "connect" then
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 return true
elseif topic == "inc_power" then
return inc_power(nvm)
elseif topic == "test_plasma" then elseif topic == "test_plasma" then
local node = minetest.get_node(pos) or {} local node = minetest.get_node(pos) or {}
return check_plasma(pos, node.param2) return check_plasma(pos, node.param2)
@ -187,6 +193,24 @@ local function on_request(pos, tlib2, topic)
elseif topic == "test_nucleus" then elseif topic == "test_nucleus" then
local node = minetest.get_node(pos) or {} local node = minetest.get_node(pos) or {}
return check_nucleus(pos, node.param2) 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 end
return false return false
end end
@ -196,3 +220,47 @@ control.register_nodes({"techage:ta5_magnet1", "techage:ta5_magnet2"}, {
on_request = on_request, 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'},
{'', '', ''},
},
})

View File

@ -50,6 +50,12 @@ minetest.register_craftitem("techage:silver_sandstone_powder", {
groups = {powder = 1}, 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_bush_leaves", output="techage:leave_powder"})
techage.add_grinder_recipe({input="default:acacia_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"}) 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="default:clay", output="techage:clay_powder"})
techage.add_grinder_recipe({input="techage:aluminum", output="techage:aluminum_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:silver_sandstone", output="techage:silver_sandstone_powder"})
techage.add_grinder_recipe({input="default:coal_lump", output="techage:graphite_powder"})

View File

@ -166,7 +166,7 @@ end
local function get_generator_data(pos, outdir, tlib2) local function get_generator_data(pos, outdir, tlib2)
local nvm = techage.get_nvm(pos) 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} return {level = (nvm.load or 0) / PWR_PERF, perf = PWR_PERF, capa = PWR_PERF * 2}
end end
end end
@ -190,7 +190,6 @@ minetest.register_node("techage:tiny_generator", {
after_place_node = function(pos, placer, itemstack) after_place_node = function(pos, placer, itemstack)
local nvm = techage.get_nvm(pos) local nvm = techage.get_nvm(pos)
local number = techage.add_node(pos, "techage:tiny_generator") local number = techage.add_node(pos, "techage:tiny_generator")
nvm.running = false
nvm.burn_cycles = 0 nvm.burn_cycles = 0
if itemstack then if itemstack then
local stack_meta = itemstack:get_meta() local stack_meta = itemstack:get_meta()

View File

@ -1,2 +0,0 @@
#!/bin/bash
pngquant --skip-if-larger --quality=70-90 --strip *.png --ext .png --force

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 B

After

Width:  |  Height:  |  Size: 588 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 400 B

After

Width:  |  Height:  |  Size: 573 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 399 B

After

Width:  |  Height:  |  Size: 515 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 B

After

Width:  |  Height:  |  Size: 351 B

BIN
textures/techage_plasma.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 865 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 273 B

After

Width:  |  Height:  |  Size: 497 B

View File

@ -114,14 +114,6 @@ local function read_state(itemstack, user, pointed_thing)
itemstack:add_wear(65636/200) itemstack:add_wear(65636/200)
return itemstack return itemstack
end end
elseif node.name == "techage:ta5_magnet1" or node.name == "techage:ta5_magnet2" then
local ctl = CTL(pos)
local has_gas = ctl.on_request(pos, nil, "test_gas") and S("yes") or S("no")
local has_power = ctl.on_request(pos, nil, "test_power") and S("yes") or S("no")
minetest.chat_send_player(user:get_player_name(), S("Power: @1, Cooling: @2", has_power, has_gas))
minetest.chat_send_player(user:get_player_name(), S("Position")..": "..minetest.pos_to_string(pos).." ")
itemstack:add_wear(65636/200)
return itemstack
elseif ndef and ndef.description then elseif ndef and ndef.description then
if ndef.techage_info then if ndef.techage_info then
local info = ndef.techage_info(pos) or "" local info = ndef.techage_info(pos) or ""