Add TA5 heat exchanger for the FR

This commit is contained in:
Joachim Stolberg 2022-01-10 21:39:36 +01:00
parent d010256b05
commit e9e5527516
37 changed files with 1216 additions and 312 deletions

View File

@ -190,7 +190,7 @@ local function fill_on_punch(nvm, empty_container, item_count, puncher)
end
local function legacy_items(full_container, item_count)
if full_container == "techage:hydrogen" then
if full_container == "techage:isobutane" then
return {container = "", size = item_count, inv_item = full_container}
elseif full_container == "techage:oil_source" then
return {container = "", size = item_count, inv_item = full_container}

View File

@ -19,55 +19,108 @@ local M = minetest.get_meta
local S = techage.S
local Cable = techage.ElectricCable
local Pipe = techage.GasPipe
local power = networks.power
local liquid = networks.liquid
local control = networks.control
minetest.register_node("techage:ta5_fr_controller", {
description = "TA5 Fusion Reactor Controller",
local CYCLE_TIME = 2
local STANDBY_TICKS = 3
local COUNTDOWN_TICKS = 3
local PWR_NEEDED = 4
local function concentrate(t)
local yes = 0
local no = 0
for _,v in ipairs(t) do
if v then
yes = yes + 1
else
no = no + 1
end
end
return yes .. " yes, " .. no .. " no"
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"
end
end
return "error"
end
local Commands = {
function(pos, outdir)
local resp = control.request(pos, Cable, outdir, "con", "test_plasma")
return "test_plasma: " .. concentrate(resp)
end,
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 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,
}
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)
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 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
end
local function after_dig_node(pos, oldnode, oldmetadata)
Cable:after_dig_node(pos)
techage.remove_node(pos, oldnode, oldmetadata)
techage.del_mem(pos)
end
minetest.register_node("techage:ta5_fr_controller_pas", {
description = S("TA5 Fusion Reactor Controller"),
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta4.png^techage_frame_ta5_top.png",
"techage_filling_ta4.png^techage_frame_ta5_top.png^techage_appl_arrow.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_filling_ta4.png^techage_frame_ta5.png",
"techage_filling_ta4.png^techage_appl_plasma.png^techage_frame_ta5.png",
},
after_place_node = function(pos, placer, itemstack)
minetest.get_node_timer(pos):start(2)
Cable:after_place_node(pos)
end,
on_timer = function(pos)
local node = minetest.get_node(pos) or {}
local outdir = networks.side_to_outdir(pos, "R")
local mem = techage.get_mem(pos)
mem.idx = ((mem.idx or 0) + 1) % 4
local cmnd = ({[0]= "test_plasma", "test_shell", "on", "off"})[mem.idx]
if mem.idx <= 1 then
local resp = control.request(
pos,
Cable,
outdir,
"con",
cmnd)
print(dump(resp))
else
local resp = control.send(
pos,
Cable,
outdir,
"con",
cmnd)
print(dump(resp))
end
return true
end,
after_dig_node = function(pos, oldnode)
Cable:after_dig_node(pos)
techage.del_mem(pos)
end,
after_place_node = after_place_node,
on_timer = node_timer,
after_dig_node = after_dig_node,
drawtype = "nodebox",
paramtype2 = "facedir",
groups = {choppy=2, cracky=2, crumbly=2},
@ -75,4 +128,35 @@ minetest.register_node("techage:ta5_fr_controller", {
sounds = default.node_sound_metal_defaults(),
})
power.register_nodes({"techage:ta5_fr_controller"}, Cable, "con", {"L", "R"})
minetest.register_node("techage:ta5_fr_controller_act", {
description = S("TA5 Fusion Reactor Controller"),
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta4.png^techage_frame_ta5_top.png^techage_appl_arrow.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",
{
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,
},
},
},
after_place_node = after_place_node,
on_timer = node_timer,
after_dig_node = after_dig_node,
drawtype = "nodebox",
paramtype2 = "facedir",
groups = {choppy=2, cracky=2, crumbly=2},
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
power.register_nodes({"techage:ta5_fr_controller_pas", "techage:ta5_fr_controller_act"}, Cable, "con", {"L", "R"})

View File

@ -20,7 +20,7 @@ local S = techage.S
local MAX_PIPE_LENGHT = 100
local power = networks.power
local liquid = networks.liquid
local Pipe = tubelib2.Tube:new({
dirs_to_check = {1,2,3,4,5,6},
@ -29,13 +29,19 @@ local Pipe = tubelib2.Tube:new({
force_to_use_tubes = false,
tube_type = "pipe3",
primary_node_names = {
"techage:ta5_pipeS", "techage:ta5_pipeA",
"techage:ta5_pipe1S", "techage:ta5_pipe1A",
"techage:ta5_pipe2S", "techage:ta5_pipe2A",
},
secondary_node_names = {},
after_place_tube = function(pos, param2, tube_type, num_tubes)
local name = minetest.get_node(pos).name
if not networks.hidden_name(pos) then
minetest.swap_node(pos, {name = "techage:ta5_pipe"..tube_type, param2 = param2 % 32})
local name = minetest.get_node(pos).name
if name == "techage:ta5_pipe1S" or name == "techage:ta5_pipe1A" then
minetest.swap_node(pos, {name = "techage:ta5_pipe1"..tube_type, param2 = param2 % 32})
else
minetest.swap_node(pos, {name = "techage:ta5_pipe2"..tube_type, param2 = param2 % 32})
end
end
M(pos):set_int("netw_param2", param2)
end,
@ -46,18 +52,18 @@ networks.use_metadata(Pipe)
-- Use global callback instead of node related functions
Pipe:register_on_tube_update2(function(pos, outdir, tlib2, node)
power.update_network(pos, outdir, tlib2, node)
liquid.update_network(pos, outdir, tlib2, node)
end)
minetest.register_node("techage:ta5_pipeS", {
minetest.register_node("techage:ta5_pipe1S", {
description = S("TA5 Pipe"),
tiles = {
"techage_ta5_gaspipe.png^[transformR90",
"techage_ta5_gaspipe.png^[transformR90",
"techage_ta5_gaspipe.png",
"techage_ta5_gaspipe.png",
"techage_ta5_gaspipe_hole2.png",
"techage_ta5_gaspipe_hole2.png",
"techage_ta5_gaspipe.png^[transformR90^[colorize:#000080:160",
"techage_ta5_gaspipe.png^[transformR90^[colorize:#000080:160",
"techage_ta5_gaspipe.png^[colorize:#000080:160",
"techage_ta5_gaspipe.png^[colorize:#000080:160",
"techage_ta5_gaspipe_hole2.png^[colorize:#000080:160",
"techage_ta5_gaspipe_hole2.png^[colorize:#000080:160",
},
after_place_node = function(pos, placer, itemstack, pointed_thing)
@ -89,15 +95,15 @@ minetest.register_node("techage:ta5_pipeS", {
sounds = default.node_sound_metal_defaults(),
})
minetest.register_node("techage:ta5_pipeA", {
minetest.register_node("techage:ta5_pipe1A", {
description = S("TA5 Pipe"),
tiles = {
"techage_ta5_gaspipe_knee2.png",
"techage_ta5_gaspipe_hole2.png^[transformR180",
"techage_ta5_gaspipe_knee.png^[transformR270",
"techage_ta5_gaspipe_knee.png",
"techage_ta5_gaspipe_knee2.png",
"techage_ta5_gaspipe_hole2.png",
"techage_ta5_gaspipe_knee2.png^[colorize:#000080:160",
"techage_ta5_gaspipe_hole2.png^[transformR180^[colorize:#000080:160",
"techage_ta5_gaspipe_knee.png^[transformR270^[colorize:#000080:160",
"techage_ta5_gaspipe_knee.png^[colorize:#000080:160",
"techage_ta5_gaspipe_knee2.png^[colorize:#000080:160",
"techage_ta5_gaspipe_hole2.png^[colorize:#000080:160",
},
after_dig_node = function(pos, oldnode, oldmetadata, digger)
@ -123,7 +129,84 @@ minetest.register_node("techage:ta5_pipeA", {
groups = {crumbly = 2, cracky = 2, snappy = 2,
not_in_creative_inventory=1, techage_trowel = 1},
sounds = default.node_sound_metal_defaults(),
drop = "techage:ta5_pipeS",
drop = "techage:ta5_pipe1S",
})
minetest.register_node("techage:ta5_pipe2S", {
description = S("TA5 Pipe"),
tiles = {
"techage_ta5_gaspipe.png^[transformR90^[colorize:#008000:160",
"techage_ta5_gaspipe.png^[transformR90^[colorize:#008000:160",
"techage_ta5_gaspipe.png^[colorize:#008000:160",
"techage_ta5_gaspipe.png^[colorize:#008000:160",
"techage_ta5_gaspipe_hole2.png^[colorize:#008000:160",
"techage_ta5_gaspipe_hole2.png^[colorize:#008000:160",
},
after_place_node = function(pos, placer, itemstack, pointed_thing)
if not Pipe:after_place_tube(pos, placer, pointed_thing) then
minetest.remove_node(pos)
return true
end
return false
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
Pipe:after_dig_tube(pos, oldnode, oldmetadata)
end,
paramtype2 = "facedir", -- important!
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-1/16, -1/16, -8/16, 1/16, 1/16, 8/16},
},
},
on_rotate = screwdriver.disallow, -- important!
paramtype = "light",
use_texture_alpha = techage.CLIP,
sunlight_propagates = true,
is_ground_content = false,
groups = {crumbly = 2, cracky = 2, snappy = 2, techage_trowel = 1},
sounds = default.node_sound_metal_defaults(),
})
minetest.register_node("techage:ta5_pipe2A", {
description = S("TA5 Pipe"),
tiles = {
"techage_ta5_gaspipe_knee2.png^[colorize:#008000:160",
"techage_ta5_gaspipe_hole2.png^[transformR180^[colorize:#008000:160",
"techage_ta5_gaspipe_knee.png^[transformR270^[colorize:#008000:160",
"techage_ta5_gaspipe_knee.png^[colorize:#008000:160",
"techage_ta5_gaspipe_knee2.png^[colorize:#008000:160",
"techage_ta5_gaspipe_hole2.png^[colorize:#008000:160",
},
after_dig_node = function(pos, oldnode, oldmetadata, digger)
Pipe:after_dig_tube(pos, oldnode, oldmetadata)
end,
paramtype2 = "facedir", -- important!
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-1/16, -8/16, -1/16, 1/16, 1/16, 1/16},
{-2/16, -0.5, -2/16, 2/16, -13/32, 2/16},
{-1/16, -1/16, -8/16, 1/16, 1/16, -1/16},
{-2/16, -2/16, -0.5, 2/16, 2/16, -13/32},
},
},
on_rotate = screwdriver.disallow, -- important!
paramtype = "light",
use_texture_alpha = techage.CLIP,
sunlight_propagates = true,
is_ground_content = false,
groups = {crumbly = 2, cracky = 2, snappy = 2,
not_in_creative_inventory=1, techage_trowel = 1},
sounds = default.node_sound_metal_defaults(),
drop = "techage:ta5_pipe2S",
})
local size1 = 1/16
@ -139,7 +222,7 @@ local Boxes = {
{ size3, -size2, -size2, 0.5, size2, size2}, -- x+
},
{
{-size1, -size1, -0.5, size1, size1, size1}, -- z- 2d5627
{-size1, -size1, -0.5, size1, size1, size1}, -- z-
{-size2, -size2, -0.5, size2, size2, -size3}, -- z-
},
{
@ -156,32 +239,58 @@ local Boxes = {
}
}
local names = networks.register_junction("techage:ta5_junctionpipe", 1/8, Boxes, Pipe, {
local names1 = networks.register_junction("techage:ta5_junctionpipe1", 1/8, Boxes, Pipe, {
description = S("TA5 Junction Pipe"),
tiles = {"techage_ta5_gaspipe_junction.png"},
tiles = {"techage_ta5_gaspipe_junction.png^[colorize:#000080:160"},
use_texture_alpha = techage.CLIP,
is_ground_content = false,
groups = {crumbly = 2, cracky = 2, snappy = 2, techage_trowel = 1},
sounds = default.node_sound_metal_defaults(),
after_place_node = function(pos, placer, itemstack, pointed_thing)
local name = "techage:ta5_junctionpipe" .. networks.junction_type(pos, Pipe)
local name = "techage:ta5_junctionpipe1" .. networks.junction_type(pos, Pipe)
minetest.swap_node(pos, {name = name, param2 = 0})
Pipe:after_place_node(pos)
end,
tubelib2_on_update2 = function(pos, dir1, tlib2, node)
if not networks.hidden_name(pos) then
local name = "techage:ta5_junctionpipe" .. networks.junction_type(pos, Pipe)
local name = "techage:ta5_junctionpipe1" .. networks.junction_type(pos, Pipe)
minetest.swap_node(pos, {name = name, param2 = 0})
end
power.update_network(pos, 0, tlib2, node)
liquid.update_network(pos, 0, tlib2, node)
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
Pipe:after_dig_node(pos)
end,
}, 25)
power.register_nodes(names, Pipe, "junc")
local names2 = networks.register_junction("techage:ta5_junctionpipe2", 1/8, Boxes, Pipe, {
description = S("TA5 Junction Pipe"),
tiles = {"techage_ta5_gaspipe_junction.png^[colorize:#008000:160"},
use_texture_alpha = techage.CLIP,
is_ground_content = false,
groups = {crumbly = 2, cracky = 2, snappy = 2, techage_trowel = 1},
sounds = default.node_sound_metal_defaults(),
after_place_node = function(pos, placer, itemstack, pointed_thing)
local name = "techage:ta5_junctionpipe2" .. networks.junction_type(pos, Pipe)
minetest.swap_node(pos, {name = name, param2 = 0})
Pipe:after_place_node(pos)
end,
tubelib2_on_update2 = function(pos, dir1, tlib2, node)
if not networks.hidden_name(pos) then
local name = "techage:ta5_junctionpipe2" .. networks.junction_type(pos, Pipe)
minetest.swap_node(pos, {name = name, param2 = 0})
end
liquid.update_network(pos, 0, tlib2, node)
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
Pipe:after_dig_node(pos)
end,
}, 25)
liquid.register_nodes(names1, Pipe, "junc")
liquid.register_nodes(names2, Pipe, "junc")
--minetest.register_craft({
-- output = "techage:ta3_junctionpipe25 2",

View File

@ -0,0 +1,130 @@
--[[
TechAge
=======
Copyright (C) 2019-2021 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA4 TES Generator (dummy)
- can be started and stopped
- provides netID of cable network
]]--
-- for lazy programmers
local M = minetest.get_meta
local S = techage.S
local Cable = techage.ElectricCable
local power = networks.power
local function swap_node(pos, name)
local node = techage.get_node_lvm(pos)
if node.name == name then
return
end
node.name = name
minetest.swap_node(pos, node)
end
minetest.register_node("techage:ta4_generator", {
description = S("TA4 Generator"),
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta4.png^techage_frame_ta4_top.png",
"techage_filling_ta4.png^techage_frame_ta4.png",
"techage_filling_ta4.png^techage_appl_hole_electric.png^techage_frame_ta4.png",
"techage_filling_ta4.png^techage_appl_open.png^techage_frame_ta4.png",
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_generator.png",
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_generator.png^[transformFX]",
},
after_place_node = function(pos)
M(pos):set_int("outdir", networks.side_to_outdir(pos, "R"))
Cable:after_place_node(pos)
end,
after_dig_node = function(pos, oldnode)
Cable:after_dig_node(pos)
techage.del_mem(pos)
end,
paramtype2 = "facedir",
groups = {cracky=2, crumbly=2, choppy=2},
on_rotate = screwdriver.disallow,
is_ground_content = false,
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("techage:ta4_generator_on", {
description = S("TA4 Generator"),
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta4.png^techage_frame_ta4_top.png",
"techage_filling_ta4.png^techage_frame_ta4.png",
"techage_filling_ta4.png^techage_appl_hole_electric.png^techage_frame_ta4.png",
"techage_filling_ta4.png^techage_appl_open.png^techage_frame_ta4.png",
{
image = "techage_filling4_ta4.png^techage_appl_generator4.png^techage_frame4_ta4.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 0.3,
},
},
{
image = "techage_filling4_ta4.png^techage_appl_generator4.png^[transformFX]^techage_frame4_ta4.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 0.3,
},
},
},
paramtype2 = "facedir",
drop = "",
groups = {not_in_creative_inventory=1},
diggable = false,
on_rotate = screwdriver.disallow,
is_ground_content = false,
sounds = default.node_sound_wood_defaults(),
})
-- The generator is a dummy, it only has to network connection to check the netID
power.register_nodes({"techage:ta4_generator", "techage:ta4_generator_on"}, Cable, "con", {"R"})
-- controlled by the turbine
techage.register_node({"techage:ta4_generator", "techage:ta4_generator_on"}, {
on_transfer = function(pos, in_dir, topic, payload)
if topic == "netID" then
local outdir = M(pos):get_int("outdir")
return networks.determine_netID(pos, Cable, outdir)
elseif topic == "start" then
swap_node(pos, "techage:ta4_generator_on")
elseif topic == "stop" then
swap_node(pos, "techage:ta4_generator")
end
end,
on_recv_message = function(pos, src, topic, payload)
return "unsupported"
end,
on_node_load = function(pos)
-- remove legacy formspec
M(pos):set_string("formspec", "")
end,
})
minetest.register_craft({
output = "techage:ta4_generator",
recipe = {
{"", "dye:blue", ""},
{"", "techage:generator", ""},
{"", "techage:ta4_wlanchip", ""},
},
})

View File

@ -0,0 +1,110 @@
--[[
TechAge
=======
Copyright (C) 2019-2022 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA5 Heat Exchanger1 (bottom part)
- has a connection to storage and turbine (via pipes)
- acts as a cable junction for Exchanger2
]]--
-- for lazy programmers
local S2P = minetest.string_to_pos
local P2S = minetest.pos_to_string
local M = minetest.get_meta
local S = techage.S
local Cable = techage.ElectricCable
local Pipe2 = techage.LiquidPipe
local Pipe3 = techage.GasPipe
local power = networks.power
local liquid = networks.liquid
local control = networks.control
local function turbine_cmnd(pos, topic, payload)
return techage.transfer(pos, "R", topic, payload, Pipe2,
{"techage:ta5_turbine", "techage:ta5_turbine_on"})
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
minetest.register_node("techage:ta5_heatexchanger1", {
description = S("TA5 Heat Exchanger 1"),
tiles = {
-- up, down, right, left, back, front
"techage_hole_ta4.png^techage_appl_arrow_white.png",
"techage_filling_ta4.png^techage_frame_ta4.png",
"techage_filling_ta4.png^techage_frameB_ta4.png^techage_appl_hole_pipe.png",
"techage_filling_ta4.png^techage_frameB_ta4.png^techage_appl_hole_ta5_pipe2.png",
"techage_filling_ta4.png^techage_frameB_ta4.png^techage_appl_hole_electric.png",
"techage_filling_ta4.png^techage_frameB_ta4.png^techage_appl_hole_electric.png",
},
after_place_node = function(pos, placer, itemstack, pointed_thing)
Cable:after_place_node(pos)
Pipe2:after_place_node(pos)
Pipe3:after_place_node(pos)
end,
tubelib2_on_update2 = function(pos, outdir, tlib2, node)
if tlib2 == Cable then
power.update_network(pos, 0, Cable, node) -- junction!!!
elseif tlib2 == Pipe2 then
power.update_network(pos, outdir, Pipe2, node)
else
power.update_network(pos, outdir, Pipe3, node)
end
end,
can_dig = function(pos, player)
if minetest.is_protected(pos, player:get_player_name()) then
return false
end
pos.y = pos.y + 1
return minetest.get_node(pos).name ~= "techage:ta5_heatexchanger2"
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
Cable:after_dig_node(pos)
Pipe2:after_dig_node(pos)
Pipe3:after_dig_node(pos)
end,
paramtype2 = "facedir",
groups = {crumbly = 2, cracky = 2, snappy = 2},
on_rotate = screwdriver.disallow,
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
liquid.register_nodes({"techage:ta5_heatexchanger1"}, Pipe2, "tank", {"R"}, {})
liquid.register_nodes({"techage:ta5_heatexchanger1"}, Pipe3, "tank", {"L"}, {})
power.register_nodes({"techage:ta5_heatexchanger1"}, Cable, "junc", {"F", "B", "U"})
-- command interface
techage.register_node({"techage:ta5_heatexchanger1"}, {
on_transfer = function(pos, indir, topic, payload)
local nvm = techage.get_nvm(pos)
-- used by heatexchanger2
if topic == "test_gas_blue" then
return control_cmnd(pos, topic)
else
return turbine_cmnd(pos, topic, payload)
end
end,
})
--minetest.register_craft({
-- output = "techage:ta5_heatexchanger1",
-- recipe = {
-- {"default:tin_ingot", "techage:electric_cableS", "default:steel_ingot"},
-- {"techage:ta4_pipeS", "basic_materials:gear_steel", "techage:ta4_pipeS"},
-- {"", "techage:baborium_ingot", ""},
-- },
--})

View File

@ -0,0 +1,339 @@
--[[
TechAge
=======
Copyright (C) 2019-2022 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA5 Heat Exchanger2 (middle part)
]]--
-- for lazy programmers
local S2P = minetest.string_to_pos
local P2S = minetest.pos_to_string
local M = minetest.get_meta
local S = techage.S
local Cable = techage.ElectricCable
local power = networks.power
local control = networks.control
local CYCLE_TIME = 2
local PWR_NEEDED = 5
local DOWN = 5 -- dir
local DESCRIPTION = S("TA5 Heat Exchanger")
local EXPECT_BLUE = 56
local EXPECT_GREEN = 52
local function heatexchanger1_cmnd(pos, topic, payload)
return techage.transfer({x = pos.x, y = pos.y - 1, z = pos.z},
nil, topic, payload, nil,
{"techage:ta5_heatexchanger1"})
end
local function heatexchanger3_cmnd(pos, topic, payload)
return techage.transfer({x = pos.x, y = pos.y + 1, z = pos.z},
nil, topic, payload, nil,
{"techage:ta5_heatexchanger3"})
end
local function swap_node(pos, name)
local node = techage.get_node_lvm(pos)
if node.name == name then
return
end
node.name = name
minetest.swap_node(pos, node)
end
local function play_sound(pos)
local mem = techage.get_mem(pos)
if not mem.handle or mem.handle == -1 then
mem.handle = minetest.sound_play("techage_booster", {
pos = pos,
gain = 0.3,
max_hear_distance = 10,
loop = true})
if mem.handle == -1 then
minetest.after(1, play_sound, pos)
end
end
end
local function stop_sound(pos)
local mem = techage.get_mem(pos)
if mem.handle then
minetest.sound_stop(mem.handle)
mem.handle = nil
end
end
local function concentrate(t)
local cnt = 0
for _,v in ipairs(t) do
if v then
cnt = cnt + 1
end
end
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 = concentrate(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 = concentrate(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
return S("Turbine error")
end
return true
end,
function(pos)
if not heatexchanger3_cmnd(pos, "turbine") then
return S("Cooler error")
end
return true
end,
}
local function can_start(pos, nvm)
for _,item in ipairs(CheckCommands) do
local res = item(pos)
if res ~= true then return res end
end
return true
end
local function start_node(pos, nvm)
play_sound(pos)
nvm.ticks = 0
heatexchanger1_cmnd(pos, "start")
end
local function stop_node(pos, nvm)
stop_sound(pos)
heatexchanger1_cmnd(pos, "stop")
end
local function formspec(self, pos, nvm)
return "size[4,2]"..
"box[0,-0.1;3.8,0.5;#c6e8ff]" ..
"label[0.2,-0.1;" .. minetest.colorize( "#000000", DESCRIPTION) .. "]" ..
"image_button[1.5,1;1,1;".. self:get_state_button_image(nvm) ..";state_button;]"..
"tooltip[1.5,1;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
local res = CheckCommands[nvm.ticks](pos)
if res ~= true then return res end
end
return true
end
local State = techage.NodeStates:new({
node_name_passive = "techage:ta5_heatexchanger2",
cycle_time = CYCLE_TIME,
infotext_name = DESCRIPTION,
standby_ticks = 0,
can_start = can_start,
start_node = start_node,
stop_node = stop_node,
formspec_func = formspec,
})
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")
stop_sound(pos)
heatexchanger1_cmnd(pos, "stop")
else
return true -- keep running
end
end
end
end
local function node_timer(pos, elapsed)
print("node_timer")
local nvm = techage.get_nvm(pos)
consume_power(pos, nvm)
local res = check_integrity(pos, nvm)
if res ~= true then
State:fault(pos, nvm, res)
stop_sound(pos)
heatexchanger1_cmnd(pos, "stop")
end
return State:is_active(nvm)
end
local function can_dig(pos, player)
if minetest.is_protected(pos, player:get_player_name()) then
return false
end
local nvm = techage.get_nvm(pos)
return not techage.is_running(nvm)
end
local function on_rightclick(pos, node, clicker)
techage.set_activeformspec(pos, clicker)
local nvm = techage.get_nvm(pos)
M(pos):set_string("formspec", formspec(State, pos, nvm))
end
local function after_place_node(pos, placer)
if techage.orientate_node(pos, "techage:ta5_heatexchanger1") then
return true
end
local meta = M(pos)
local nvm = techage.get_nvm(pos)
local own_num = techage.add_node(pos, "techage:ta5_heatexchanger2")
meta:set_string("owner", placer:get_player_name())
meta:set_string("infotext", DESCRIPTION..": "..own_num)
meta:set_string("formspec", formspec(State, pos, nvm))
Cable:after_place_node(pos, {DOWN})
State:node_init(pos, nvm, own_num)
end
local function after_dig_node(pos, oldnode, oldmetadata, digger)
Cable:after_dig_node(pos)
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
-- Middle node with the formspec from the bottom node
minetest.register_node("techage:ta5_heatexchanger2", {
description = DESCRIPTION,
tiles = {
-- up, down, right, left, back, front
"techage_hole_ta4.png",
"techage_hole_ta4.png",
"techage_filling_ta4.png^techage_frameM_ta4.png^techage_appl_tes_turb.png",
"techage_filling_ta4.png^techage_frameM_ta4.png",
"techage_filling_ta4.png^techage_frameM_ta4.png^techage_appl_ribsB.png",
"techage_filling_ta4.png^techage_frameM_ta4.png^techage_appl_ribsB.png",
},
selection_box = {
type = "fixed",
fixed = {-1/2, -1.5/2, -1/2, 1/2, 1/2, 1/2},
},
on_receive_fields = on_receive_fields,
on_rightclick = on_rightclick,
on_timer = node_timer,
after_place_node = after_place_node,
can_dig = can_dig,
after_dig_node = after_dig_node,
get_storage_data = get_storage_data,
paramtype2 = "facedir",
groups = {crumbly = 2, cracky = 2, snappy = 2},
on_rotate = screwdriver.disallow,
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
power.register_nodes({"techage:ta5_heatexchanger2"}, Cable, "con", {"D"})
techage.register_node({"techage:ta5_heatexchanger2"}, {
on_recv_message = function(pos, src, topic, payload)
local nvm = techage.get_nvm(pos)
if topic == "state" then
if techage.is_running(nvm) then
return "running"
else
return "stopped"
end
elseif topic == "delivered" then
local data = power.get_network_data(pos, Cable, DOWN)
return data.consumed - data.provided
elseif topic == "on" then
start_node(pos, techage.get_nvm(pos))
return true
elseif topic == "off" then
stop_node(pos, techage.get_nvm(pos))
return true
else
return "unsupported"
end
end,
on_node_load = function(pos, node)
local nvm = techage.get_nvm(pos)
if techage.is_running(nvm) then
play_sound(pos)
else
stop_sound(pos)
end
-- Attempt to restart the system as the heat exchanger goes into error state
-- when parts of the storage block are unloaded.
if nvm.techage_state == techage.FAULT then
start_node(pos, nvm)
end
end,
})
control.register_nodes({"techage:ta5_heatexchanger2"}, {
on_receive = function(pos, tlib2, topic, payload)
end,
on_request = function(pos, tlib2, topic)
if topic == "info" then
local nvm = techage.get_nvm(pos)
return {
type = DESCRIPTION,
number = M(pos):get_string("node_number") or "",
running = techage.is_running(nvm) or false,
capa = nvm.capa_max or 1,
load = nvm.capa or 0,
}
end
return false
end,
}
)
--minetest.register_craft({
-- output = "techage:ta5_heatexchanger2",
-- recipe = {
-- {"default:tin_ingot", "", "default:steel_ingot"},
-- {"", "techage:ta4_wlanchip", ""},
-- {"", "techage:baborium_ingot", ""},
-- },
--})

View File

@ -0,0 +1,107 @@
--[[
TechAge
=======
Copyright (C) 2019-2022 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA5 Heat Exchanger3 (top part)
]]--
-- for lazy programmers
local M = minetest.get_meta
local S = techage.S
local Pipe2 = techage.LiquidPipe
local Pipe3 = techage.GasPipe
local liquid = networks.liquid
local control = networks.control
local function orientate_node(pos, name)
local node = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
if node.name == name then
local param2 = node.param2
node = minetest.get_node(pos)
node.param2 = param2
minetest.swap_node(pos, node)
else
minetest.remove_node(pos)
return true
end
end
local function after_place_node(pos)
if orientate_node(pos, "techage:ta5_heatexchanger2") then
return true
end
Pipe2:after_place_node(pos)
Pipe3:after_place_node(pos)
end
local function after_dig_node(pos, oldnode)
Pipe2:after_dig_node(pos)
Pipe3:after_dig_node(pos)
end
local function turbine_cmnd(pos, topic, payload)
return techage.transfer(pos, "R", topic, payload, Pipe2,
{"techage:ta5_turbine", "techage:ta5_turbine_on"})
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
minetest.register_node("techage:ta5_heatexchanger3", {
description = S("TA4 Heat Exchanger 3"),
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta4.png^techage_frame_ta5_top.png",
"techage_hole_ta4.png",
"techage_filling_ta4.png^techage_frameT_ta5.png^techage_appl_hole_pipe.png",
"techage_filling_ta4.png^techage_frameT_ta5.png^techage_appl_hole_ta5_pipe1.png",
"techage_filling_ta4.png^techage_frameT_ta5.png^techage_appl_ribsT.png",
"techage_filling_ta4.png^techage_frameT_ta5.png^techage_appl_ribsT.png",
},
after_place_node = after_place_node,
after_dig_node = after_dig_node,
paramtype2 = "facedir",
groups = {crumbly = 2, cracky = 2, snappy = 2},
on_rotate = screwdriver.disallow,
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
liquid.register_nodes({"techage:ta5_heatexchanger3"}, Pipe2, "tank", {"R"}, {})
liquid.register_nodes({"techage:ta5_heatexchanger3"}, Pipe3, "tank", {"L"}, {})
-- command interface, used by heatexchanger2
techage.register_node({"techage:ta5_heatexchanger3"}, {
on_transfer = function(pos, indir, topic, payload)
if topic == "turbine" then
return turbine_cmnd(pos, topic, payload)
else
return control_cmnd(pos, topic)
end
end,
})
--minetest.register_craft({
-- output = "techage:ta5_heatexchanger3",
-- recipe = {
-- {"default:tin_ingot", "dye:blue", "default:steel_ingot"},
-- {"techage:ta4_pipeS", "basic_materials:gear_steel", "techage:ta4_pipeS"},
-- {"", "techage:baborium_ingot", ""},
-- },
--})
techage.orientate_node = orientate_node

View File

@ -23,28 +23,17 @@ local Pipe = techage.GasPipe
local power = networks.power
local liquid = networks.liquid
local control = networks.control
local tubelib2_get_pos = tubelib2.get_pos
local tubelib2_side_to_dir = tubelib2.side_to_dir
local CAPACITY = 20
local SHELLBLOCKS = {"techage:ta5_fr_shell1", "techage:ta5_fr_shell2"}
local function get_pos(pos, sides, param2)
local pos1 = {x = pos.x, y = pos.y, z = pos.z}
for side in sides:gmatch"." do
pos1 = tubelib2_get_pos(pos1, tubelib2_side_to_dir(side, param2))
end
return pos1
end
local SHELLBLOCKS = {"techage:ta5_fr_shell", "techage:ta5_fr_nucleus", "techage:ta5_magnet1", "techage:ta5_magnet2"}
minetest.register_node("techage:ta5_magnet1", {
description = S("TA5 Fusion Reactor Magnet 1"),
tiles = {
-- up, down, right, left, back, front
"techage_collider_magnet.png^techage_appl_hole_ta5_pipe.png^techage_steel_tiles_top.png^[transformR180]",
"techage_collider_magnet.png^techage_steel_tiles_top.png",
"techage_collider_magnet.png^techage_appl_hole_ta5_pipe1.png^techage_steel_tiles_top.png^[transformR180]",
"techage_collider_magnet.png^techage_appl_hole_ta5_pipe2.png^techage_steel_tiles_top.png",
"techage_collider_magnet.png^techage_steel_tiles_side.png",
"techage_collider_magnet.png^techage_appl_hole_electric.png^techage_steel_tiles_side.png^[transformR180]",
"techage_collider_magnet.png^techage_steel_tiles_side.png^[transformR180]",
"techage_collider_magnet.png^techage_appl_hole_electric.png",
"techage_steel_tiles.png",
},
@ -75,11 +64,11 @@ minetest.register_node("techage:ta5_magnet2", {
description = S("TA5 Fusion Reactor Magnet 2"),
tiles = {
-- up, down, right, left, back, front
"techage_collider_magnet.png^techage_appl_hole_ta5_pipe.png^techage_steel_tiles_top2.png^[transformR180]",
"techage_collider_magnet.png^techage_appl_hole_ta5_pipe.png^techage_steel_tiles_top2.png^[transformR270]",
"techage_collider_magnet.png^techage_appl_hole_ta5_pipe1.png^techage_steel_tiles_top2.png^[transformR180]",
"techage_collider_magnet.png^techage_appl_hole_ta5_pipe2.png^techage_steel_tiles_top2.png^[transformR270]",
"techage_steel_tiles.png",
"techage_collider_magnet.png^techage_appl_hole_electric.png^techage_steel_tiles_side.png^[transformR180]",
"techage_collider_magnet.png^techage_appl_hole_electric.png^techage_steel_tiles_side.png",
"techage_collider_magnet.png^techage_steel_tiles_side.png^[transformR180]",
"techage_collider_magnet.png^techage_steel_tiles_side.png",
"techage_steel_tiles.png",
},
after_place_node = function(pos, placer, itemstack)
@ -105,142 +94,70 @@ minetest.register_node("techage:ta5_magnet2", {
sounds = default.node_sound_metal_defaults(),
})
minetest.register_node("techage:ta5_magnet3", {
description = S("TA5 Fusion Reactor Magnet 3"),
drawtype = "nodebox",
tiles = {
-- up, down, right, left, back, front
"techage_collider_magnet.png^techage_appl_hole_ta5_pipe.png^techage_steel_tiles_top.png^[transformR180]",
"techage_collider_magnet.png^techage_steel_tiles_top.png",
"techage_collider_magnet.png^techage_appl_hole_electric.png^techage_steel_tiles_side.png",
"techage_collider_magnet.png^techage_appl_hole_electric.png^techage_steel_tiles_side.png^[transformR180]",
"techage_magnet_hole.png",
"techage_steel_tiles.png",
},
node_box = {
type = "fixed",
fixed = {
{-8/16, -8/16, -8/16, 8/16, 8/16, 2/16},
{-8/16, -8/16, 2/16, -2/16, 8/16, 8/16},
{ 2/16, -8/16, 2/16, 8/16, 8/16, 8/16},
{-8/16, -8/16, 2/16, 8/16, -2/16, 8/16},
{-8/16, 2/16, 2/16, 8/16, 8/16, 8/16},
},
},
selection_box = {
type = "fixed",
fixed = {-8/16, -8/16, -8/16, 8/16, 8/16, 8/16},
},
after_place_node = function(pos, placer, itemstack)
Pipe:after_place_node(pos)
Cable:after_place_node(pos)
end,
ta_rotate_node = function(pos, node, new_param2)
Pipe:after_dig_node(pos)
Cable:after_dig_node(pos)
minetest.swap_node(pos, {name = node.name, param2 = new_param2})
Pipe:after_place_node(pos)
Cable:after_place_node(pos)
end,
after_dig_node = function(pos, oldnode)
Pipe:after_dig_node(pos)
Cable:after_dig_node(pos)
techage.del_mem(pos)
end,
drawtype = "nodebox",
paramtype2 = "facedir",
paramtype = "light",
use_texture_alpha = "blend",
groups = {choppy=2, cracky=2, crumbly=2},
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
power.register_nodes({"techage:ta5_magnet1", "techage:ta5_magnet2"}, Cable, "con", {"L", "B"})
power.register_nodes({"techage:ta5_magnet3"}, Cable, "con", {"L", "R"})
liquid.register_nodes({"techage:ta5_magnet1", "techage:ta5_magnet2", "techage:ta5_magnet3"}, Pipe, "tank", {"U"}, {
capa = CAPACITY,
peek = function(pos, indir)
local nvm = techage.get_nvm(pos)
return liquid.srv_peek(nvm)
end,
put = function(pos, indir, name, amount)
local nvm = techage.get_nvm(pos)
return liquid.srv_put(nvm, name, amount, CAPACITY)
end,
take = function(pos, indir, name, amount)
local nvm = techage.get_nvm(pos)
return liquid.srv_take(nvm, name, amount)
end,
untake = function(pos, indir, name, amount)
local nvm = techage.get_nvm(pos)
liquid.srv_put(nvm, name, amount, CAPACITY)
end,
})
power.register_nodes({"techage:ta5_magnet1"}, Cable, "con", {"B"})
liquid.register_nodes({"techage:ta5_magnet1", "techage:ta5_magnet2"}, Pipe, "tank", {"U", "D"}, {})
local function check_plasma(pos, param2)
local pos1 = get_pos(pos, "F", 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 == "techage:plasma1" or node.name == "techage:plasma2"
--techage.mark_position("singleplayer", pos1, "pos1", nil, 2)
return node.name == "air"
end
local function swap_plasma(pos, name, param2)
local pos1 = get_pos(pos, "F", param2)
local pos1 = networks.get_relpos(pos, "F", param2)
minetest.swap_node(pos1, {name = name, param2 = param2})
end
local function check_steel(pos, param2)
local pos1 = get_pos(pos, "D", param2)
local pos2 = get_pos(pos, "BU", param2)
local function check_shell(pos, param2)
local pos1 = networks.get_relpos(pos, "D", param2)
local pos2 = networks.get_relpos(pos, "BU", param2)
local _,t = minetest.find_nodes_in_area(pos1, pos2, SHELLBLOCKS)
local cnt = 0
for k,v in pairs(t) do
cnt = cnt + v
end
print("shell", cnt)
return cnt == 5
return cnt == 6
end
local function on_receive(pos, tlib2, topic, payload)
local nvm = techage.get_nvm(pos)
if topic == "on" then
nvm.running = true
elseif topic == "off" then
nvm.running = false
local function check_nucleus(pos, param2)
local pos1 = networks.get_relpos(pos, "B", param2)
local node = minetest.get_node(pos1) or {}
if node.name == "techage:ta5_fr_nucleus" then
return pos1
end
end
local function on_receive3(pos, tlib2, topic, payload)
local function on_receive(pos, tlib2, topic, payload)
--print("on_receive", topic)
local nvm = techage.get_nvm(pos)
if topic == "on" then
nvm.running = true
local node = minetest.get_node(pos) or {}
swap_plasma(pos, "techage:plasma2", node.param2)
elseif topic == "off" then
nvm.running = false
local node = minetest.get_node(pos) or {}
swap_plasma(pos, "techage:plasma1", node.param2)
end
end
local function on_request(pos, tlib2, topic)
--print("on_request", topic)
local nvm = techage.get_nvm(pos)
if topic == "state" then
if not nvm.liquid or not nvm.liquid.amount or nvm.liquid.amount < CAPACITY then
return false, "no gas"
elseif nvm.liquid.name ~= "techage:isobutane" then
return false, "wrong gas"
elseif nvm.running then
return false, "stopped"
end
return true, "running"
if topic == "test_power" and tlib2 == Cable then
return true
elseif topic == "test_gas_blue" and tlib2 == Pipe then
nvm.gas_cnt = 1
return true
elseif topic == "test_gas_green" and tlib2 == Pipe then
nvm.gas_cnt = (nvm.gas_cnt or 0) - 1
return nvm.gas_cnt == 0
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_steel(pos, node.param2)
return check_shell(pos, node.param2)
elseif topic == "test_nucleus" then
local node = minetest.get_node(pos) or {}
return check_nucleus(pos, node.param2)
end
return false
end
@ -250,9 +167,3 @@ control.register_nodes({"techage:ta5_magnet1", "techage:ta5_magnet2"}, {
on_request = on_request,
}
)
control.register_nodes({"techage:ta5_magnet3"}, {
on_receive = on_receive3,
on_request = on_request,
}
)

View File

@ -1,73 +0,0 @@
--[[
TechAge
=======
Copyright (C) 2019-2022 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA5 Fusion Reactor Plasma
]]--
-- for lazy programmers
local S2P = minetest.string_to_pos
local P2S = minetest.pos_to_string
local M = minetest.get_meta
local S = techage.S
local MAGNETS = {"techage:ta5_magnet1", "techage:ta5_magnet2", "techage:ta5_magnet3"}
minetest.register_node("techage:plasma2", {
description = "TA5 Plasma",
tiles = {
"techage_plasma1.png",
"techage_plasma1.png",
"techage_plasma1.png",
"techage_plasma1.png",
{
image = "techage_plasma2.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 64,
aspect_h = 64,
length = 0.5,
},
},
"techage_plasma1.png",
},
node_box = {
type = "fixed",
fixed = {
{-8/16, -4/16, -4/16, 8/16, 4/16, 4/16},
},
},
drawtype = "nodebox",
paramtype2 = "facedir",
paramtype = "light",
light_source = 14,
drop = "",
use_texture_alpha = "blend",
groups = {choppy=2, cracky=2, crumbly=2},
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
minetest.register_node("techage:plasma1", {
description = "TA5 Plasma",
tiles = {
"techage_plasma1.png",
},
drawtype = "nodebox",
paramtype2 = "facedir",
paramtype = "light",
light_source = 0,
drop = "",
use_texture_alpha = "blend",
groups = {choppy=2, cracky=2, crumbly=2},
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})

View File

@ -18,8 +18,8 @@ local P2S = minetest.pos_to_string
local M = minetest.get_meta
local S = techage.S
minetest.register_node("techage:ta5_fr_shell1", {
description = "TA5 Fusion Reactor Shell 1",
minetest.register_node("techage:ta5_fr_shell", {
description = "TA5 Fusion Reactor Shell",
tiles = {
"techage_reactor_shell.png",
},
@ -32,23 +32,10 @@ minetest.register_node("techage:ta5_fr_shell1", {
sounds = default.node_sound_metal_defaults(),
})
minetest.register_node("techage:ta5_fr_shell2", {
description = "TA5 Fusion Reactor Shell 2",
minetest.register_node("techage:ta5_fr_nucleus", {
description = "TA5 Fusion Reactor Nucleus",
tiles = {
"techage_reactor_shell.png",
},
node_box = {
type = "fixed",
fixed = {
{-8/16, -8/16, -8/16, -2/16, 8/16, 8/16},
{ 2/16, -8/16, -8/16, 8/16, 8/16, 8/16},
{-8/16, -8/16, -8/16, 8/16, -2/16, 8/16},
{-8/16, 2/16, -8/16, 8/16, 8/16, 8/16},
},
},
selection_box = {
type = "fixed",
fixed = {-8/16, -8/16, -8/16, 8/16, 8/16, 8/16},
"techage_reactor_shell.png^techage_collider_detector_core.png",
},
drawtype = "nodebox",
paramtype2 = "facedir",

167
fusion_reactor/turbine.lua Normal file
View File

@ -0,0 +1,167 @@
--[[
TechAge
=======
Copyright (C) 2019-2022 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA5 Gas Turbine
]]--
-- for lazy programmers
local M = minetest.get_meta
local S = techage.S
local Pipe = techage.LiquidPipe
local function generator_cmnd(pos, topic, payload)
return techage.transfer(pos, "R", topic, payload, nil,
{"techage:ta5_generator", "techage:ta5_generator_on"})
end
local function swap_node(pos, name)
local node = techage.get_node_lvm(pos)
if node.name == name then
return
end
node.name = name
minetest.swap_node(pos, node)
end
local function play_sound(pos)
local mem = techage.get_mem(pos)
if not mem.handle or mem.handle == -1 then
mem.handle = minetest.sound_play("techage_turbine", {
pos = pos,
gain = 0.4,
max_hear_distance = 10,
loop = true})
if mem.handle == -1 then
minetest.after(1, play_sound, pos)
end
end
end
local function stop_sound(pos)
local mem = techage.get_mem(pos)
if mem.handle then
minetest.sound_stop(mem.handle)
mem.handle = nil
end
end
minetest.register_node("techage:ta5_turbine", {
description = S("TA5 Turbine"),
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta4.png^techage_frame_ta5_top.png^techage_appl_hole_pipe.png",
"techage_filling_ta4.png^techage_frame_ta4_bottom.png",
"techage_filling_ta4.png^techage_appl_open.png^techage_frame_ta5.png",
"techage_filling_ta4.png^techage_frame_ta5.png^techage_appl_hole_pipe.png",
"techage_filling_ta4.png^techage_appl_turbine.png^techage_frame_ta5.png",
"techage_filling_ta4.png^techage_appl_turbine.png^techage_frame_ta5.png",
},
after_place_node = function(pos)
Pipe:after_place_node(pos)
end,
after_dig_node = function(pos, oldnode)
stop_sound(pos)
Pipe:after_dig_node(pos)
techage.del_mem(pos)
end,
networks = {
pipe2 = {},
},
paramtype2 = "facedir",
groups = {cracky=2, crumbly=2, choppy=2},
on_rotate = screwdriver.disallow,
is_ground_content = false,
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("techage:ta5_turbine_on", {
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta4.png^techage_frame_ta5_top.png^techage_appl_hole_pipe.png",
"techage_filling_ta4.png^techage_frame_ta4_bottom.png",
"techage_filling_ta4.png^techage_appl_open.png^techage_frame_ta5.png",
"techage_filling_ta4.png^techage_frame_ta5.png^techage_appl_hole_pipe.png",
{
image = "techage_filling4_ta4.png^techage_appl_turbine4.png^techage_frame4_ta5.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 0.4,
},
},
{
image = "techage_filling4_ta4.png^techage_appl_turbine4.png^techage_frame4_ta5.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 0.4,
},
},
},
tubelib2_on_update2 = function(pos, outdir, tlib2, node)
swap_node(pos, "techage:ta5_turbine")
stop_sound(pos)
generator_cmnd(pos, "stop")
end,
networks = {
pipe2 = {},
},
paramtype2 = "facedir",
groups = {not_in_creative_inventory=1},
diggable = false,
on_rotate = screwdriver.disallow,
is_ground_content = false,
sounds = default.node_sound_wood_defaults(),
})
Pipe:add_secondary_node_names({"techage:ta5_turbine", "techage:ta5_turbine_on"})
Pipe:set_valid_sides("techage:ta5_turbine", {"L", "U"})
Pipe:set_valid_sides("techage:ta5_turbine_on", {"L", "U"})
techage.register_node({"techage:ta5_turbine", "techage:ta5_turbine_on"}, {
on_transfer = function(pos, in_dir, topic, payload)
local nvm = techage.get_nvm(pos)
if topic == "start" then -- used by heatexchanger1
swap_node(pos, "techage:ta5_turbine_on")
play_sound(pos)
return generator_cmnd(pos, topic, payload)
elseif topic == "stop" then -- used by heatexchanger1
swap_node(pos, "techage:ta5_turbine")
stop_sound(pos)
return generator_cmnd(pos, topic, payload)
elseif topic == "turbine" then -- used by heatexchanger1
return true
else -- used by heatexchanger1
return generator_cmnd(pos, topic, payload)
end
end,
on_node_load = function(pos, node)
if node.name == "techage:ta5_turbine_on" then
play_sound(pos)
end
end,
})
--minetest.register_craft({
-- output = "techage:ta5_turbine",
-- recipe = {
-- {"", "dye:blue", ""},
-- {"", "techage:turbine", ""},
-- {"", "techage:ta4_wlanchip", ""},
-- },
--})

View File

@ -172,6 +172,8 @@ dofile(MP.."/ta2_energy_storage/ta2_weight_chest.lua")
dofile(MP.."/liquids/liquid_pipe.lua")
dofile(MP.."/liquids/valve.lua")
dofile(MP.."/liquids/pipe_wall_entry.lua")
dofile(MP.."/fusion_reactor/gas_pipe.lua")
-- Basic Machines
dofile(MP.."/basic_machines/consumer.lua") -- consumer base model
@ -387,7 +389,7 @@ dofile(MP.."/items/moreblocks.lua")
dofile(MP.."/carts/tank_cart.lua")
dofile(MP.."/carts/chest_cart.lua")
-- Collider
-- TA4 Collider
dofile(MP.."/collider/vacuumtube.lua")
dofile(MP.."/collider/magnet.lua")
dofile(MP.."/collider/inlets.lua")
@ -395,14 +397,19 @@ dofile(MP.."/collider/cooler.lua")
dofile(MP.."/collider/detector.lua")
dofile(MP.."/collider/worker.lua")
-- TA5 Teleport
dofile(MP.."/teleport/teleport_tube.lua")
dofile(MP.."/teleport/teleport_pipe.lua")
-- TA5 Fusion Reactor
dofile(MP.."/fusion_reactor/shell.lua")
dofile(MP.."/fusion_reactor/gas_pipe.lua")
dofile(MP.."/fusion_reactor/magnet.lua")
dofile(MP.."/fusion_reactor/plasma.lua")
dofile(MP.."/fusion_reactor/controller.lua")
dofile(MP.."/fusion_reactor/heatexchanger3.lua")
dofile(MP.."/fusion_reactor/heatexchanger2.lua")
dofile(MP.."/fusion_reactor/heatexchanger1.lua")
--dofile(MP.."/fusion_reactor/generator.lua")
dofile(MP.."/fusion_reactor/turbine.lua")
-- Prevent other mods from using IE
techage.IE = nil

View File

@ -38,3 +38,29 @@ minetest.register_on_mods_loaded(function()
end)
minetest.override_item("default:gravel", {groups = {crumbly = 2, gravel = 1, falling_node = 1}})
-- Register all known mobs mods for the move/fly controllers
techage.register_mobs_mods("ts_skins_dummies")
techage.register_mobs_mods("mobs")
techage.register_mobs_mods("draconis")
techage.register_mobs_mods("mobkit")
techage.register_mobs_mods("animalia")
techage.register_mobs_mods("mobs_animal")
techage.register_mobs_mods("mobs_monster")
techage.register_mobs_mods("dmobs")
techage.register_mobs_mods("mob_horse")
techage.register_mobs_mods("petz")
techage.register_mobs_mods("mobs_npc")
techage.register_mobs_mods("livingnether")
techage.register_mobs_mods("extra_mobs")
techage.register_mobs_mods("nssm")
techage.register_mobs_mods("goblins")
techage.register_mobs_mods("animalworld")
techage.register_mobs_mods("aliveai")
techage.register_mobs_mods("people")
techage.register_mobs_mods("paleotest")
techage.register_mobs_mods("mobs_balrog")
techage.register_mobs_mods("wildlife")
techage.register_mobs_mods("mobs_skeletons")
techage.register_mobs_mods("mobs_dwarves")
techage.register_mobs_mods("mobf_trader")

View File

@ -20,7 +20,7 @@ local S = techage.S
local MAX_PIPE_LENGHT = 100
local power = networks.power
local liquid = networks.liquid
local Pipe = tubelib2.Tube:new({
dirs_to_check = {1,2,3,4,5,6},
@ -47,7 +47,7 @@ local Pipe = tubelib2.Tube:new({
-- Use global callback instead of node related functions
Pipe:register_on_tube_update2(function(pos, outdir, tlib2, node)
power.update_network(pos, outdir, tlib2, node)
liquid.update_network(pos, outdir, tlib2, node)
end)
minetest.register_node("techage:ta3_pipeS", {
@ -172,14 +172,14 @@ local names = networks.register_junction("techage:ta3_junctionpipe", 1/8, Boxes,
tubelib2_on_update2 = function(pos, dir1, tlib2, node)
local name = "techage:ta3_junctionpipe" .. networks.junction_type(pos, Pipe)
minetest.swap_node(pos, {name = name, param2 = 0})
power.update_network(pos, 0, tlib2, node)
liquid.update_network(pos, 0, tlib2, node)
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
Pipe:after_dig_node(pos)
end,
}, 25)
power.register_nodes(names, Pipe, "junc")
liquid.register_nodes(names, Pipe, "junc")
minetest.register_craft({
output = "techage:ta3_junctionpipe25 2",

View File

@ -3,7 +3,7 @@
TechAge
=======
Copyright (C) 2019-2021 Joachim Stolberg
Copyright (C) 2019-2022 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
@ -66,7 +66,7 @@ local function pumping(pos, nvm, state, capa)
state:blocked(pos, nvm)
return 0
end
state:keep_running(pos, nvm, COUNTDOWN_TICKS)
state:keep_running(pos, nvm, COUNTDOWN_TICKS)
return taken - leftover
end
state:keep_running(pos, nvm, COUNTDOWN_TICKS)
@ -133,7 +133,7 @@ end
local ta3_tiles_pas = {
-- up, down, right, left, back, front
"techage_filling_ta3.png^techage_frame_ta3_top.png^techage_appl_arrow.png",
"techage_filling_ta3.png^techage_frame_ta3.png",
"techage_filling_ta3.png^techage_frame_ta3_bottom.png",
"techage_filling_ta3.png^techage_appl_hole_pipe.png^techage_frame_ta3.png",
"techage_filling_ta3.png^techage_appl_hole_pipe.png^techage_frame_ta3.png",
"techage_filling_ta3.png^techage_appl_pump.png^techage_frame_ta3.png^[transformFX",
@ -143,7 +143,7 @@ local ta3_tiles_pas = {
local ta4_tiles_pas = {
-- up, down, right, left, back, front
"techage_filling_ta4.png^techage_frame_ta4_top.png^techage_appl_arrow.png",
"techage_filling_ta4.png^techage_frame_ta4.png",
"techage_filling_ta4.png^techage_frame_ta4_bottom.png",
"techage_filling_ta4.png^techage_appl_hole_pipe.png^techage_frame_ta4.png",
"techage_filling_ta4.png^techage_appl_hole_pipe.png^techage_frame_ta4.png",
"techage_filling_ta4.png^techage_appl_pump.png^techage_frame_ta4.png^[transformFX",
@ -153,7 +153,7 @@ local ta4_tiles_pas = {
local ta3_tiles_act = {
-- up, down, right, left, back, front
"techage_filling_ta3.png^techage_frame_ta3_top.png^techage_appl_arrow.png",
"techage_filling_ta3.png^techage_frame_ta3.png",
"techage_filling_ta3.png^techage_frame_ta3_bottom.png",
"techage_filling_ta3.png^techage_appl_hole_pipe.png^techage_frame_ta3.png",
"techage_filling_ta3.png^techage_appl_hole_pipe.png^techage_frame_ta3.png",
{
@ -181,7 +181,7 @@ local ta3_tiles_act = {
local ta4_tiles_act = {
-- up, down, right, left, back, front
"techage_filling_ta4.png^techage_frame_ta4_top.png^techage_appl_arrow.png",
"techage_filling_ta4.png^techage_frame_ta4.png",
"techage_filling_ta4.png^techage_frame_ta4_bottom.png",
"techage_filling_ta4.png^techage_appl_hole_pipe.png^techage_frame_ta4.png",
"techage_filling_ta4.png^techage_appl_hole_pipe.png^techage_frame_ta4.png",
{

View File

@ -91,7 +91,7 @@ minetest.register_node("techage:ta3_tank", {
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta3.png^techage_frame_ta3_top.png",
"techage_filling_ta3.png^techage_frame_ta3.png",
"techage_filling_ta3.png^techage_frame_ta3_bottom.png",
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_tank.png",
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_tank.png",
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_tank.png",
@ -197,7 +197,7 @@ minetest.register_node("techage:ta4_tank", {
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta4.png^techage_frame_ta4_top.png",
"techage_filling_ta4.png^techage_frame_ta4.png",
"techage_filling_ta4.png^techage_frame_ta4_bottom.png",
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_tank.png",
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_tank.png",
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_tank.png",

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 706 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 330 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 141 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 132 B

After

Width:  |  Height:  |  Size: 119 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 B

After

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 193 B

After

Width:  |  Height:  |  Size: 163 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 175 B

After

Width:  |  Height:  |  Size: 151 B

View File

@ -19,6 +19,9 @@ local Cable2 = techage.TA4_Cable
local Pipe2 = techage.LiquidPipe
local menu = techage.menu
local N = techage.get_node_lvm
local CTL = function(pos) return (minetest.registered_nodes[N(pos).name] or {}).control end
local function network_check(start_pos, Cable, player_name)
-- local ndef = techage.networks.net_def(start_pos, Cable.tube_type)
-- local outdir = nil
@ -61,17 +64,6 @@ local function read_state(itemstack, user, pointed_thing)
minetest.chat_send_player(user:get_player_name(), S("Biome")..": "..name..", "..S("Position temperature")..": "..math.floor(data.heat).." ")
end
if ndef and ndef.networks then
local player_name = user:get_player_name()
if ndef.networks.ele1 then
network_check(pos, Cable1, player_name)
elseif ndef.networks.ele2 then
network_check(pos, Cable2, player_name)
elseif ndef.networks.pipe2 then
network_check(pos, Pipe2, player_name)
end
end
if number then
if ndef and ndef.description then
local info = techage.send_single("0", number, "info", nil)
@ -122,6 +114,14 @@ local function read_state(itemstack, user, pointed_thing)
itemstack:add_wear(65636/200)
return itemstack
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
if ndef.techage_info then
local info = ndef.techage_info(pos) or ""