mods that hopefully work for a TechAge-based pack

This commit is contained in:
tangent committed 2026-09-09 06:27:51 -06:00
1 parent 4e6b08d194
commit c27db2a537
6234 files changed
+375578

No files matched your search

@@ -0,0 +1,134 @@
--[[
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",
{
name = "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,
},
},
{
name = "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 node = minetest.get_node(pos)
if in_dir ~= techage.side_to_indir("L", node.param2) then
return false
end
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", ""},
},
})
@@ -0,0 +1,101 @@
--[[
TechAge
=======
Copyright (C) 2019-2021 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA4 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 Pipe = techage.LiquidPipe
local power = networks.power
local function turbine_cmnd(pos, topic, payload)
return techage.transfer(pos, "R", topic, payload, Pipe,
{"techage:ta4_turbine", "techage:ta4_turbine_on", "techage:ta4_collider_cooler"})
end
local function inlet_cmnd(pos, topic, payload)
return techage.transfer(pos, "L", topic, payload, Pipe,
{"techage:ta4_pipe_inlet", "techage:ta4_collider_pipe_inlet"})
end
minetest.register_node("techage:heatexchanger1", {
description = S("TA4 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_pipe.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)
Pipe:after_place_node(pos)
end,
tubelib2_on_update2 = function(pos, outdir, tlib2, node)
if tlib2 == Cable then
power.update_network(pos, 0, tlib2, 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:heatexchanger2"
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
Cable:after_dig_node(pos)
Pipe:after_dig_node(pos)
end,
networks = {},
paramtype2 = "facedir",
groups = {crumbly = 2, cracky = 2, snappy = 2},
on_rotate = screwdriver.disallow,
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
Pipe:add_secondary_node_names({"techage:heatexchanger1"})
Pipe:set_valid_sides("techage:heatexchanger1", {"R", "L"})
power.register_nodes({"techage:heatexchanger1"}, Cable, "junc", {"F", "B", "U"})
-- command interface
techage.register_node({"techage:heatexchanger1"}, {
on_transfer = function(pos, indir, topic, payload)
local nvm = techage.get_nvm(pos)
-- used by heatexchanger2
if topic == "diameter" or topic == "volume" or topic == "window" or topic == "detector" then
return inlet_cmnd(pos, topic, payload)
else
return turbine_cmnd(pos, topic, payload)
end
end,
})
minetest.register_craft({
output = "techage:heatexchanger1",
recipe = {
{"default:tin_ingot", "techage:electric_cableS", "default:steel_ingot"},
{"techage:ta4_pipeS", "basic_materials:gear_steel", "techage:ta4_pipeS"},
{"", "techage:baborium_ingot", ""},
},
})
@@ -0,0 +1,436 @@
--[[
TechAge
=======
Copyright (C) 2019-2022 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA4 Heat Exchanger2 (middle part)
(alternatively used as cooler for the TA4 collider)
]]--
-- 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 Pipe = techage.LiquidPipe
local power = networks.power
local control = networks.control
local CYCLE_TIME = 2
local GRVL_CAPA = 500
local PWR_CAPA = {
[5] = GRVL_CAPA * 3 * 3 * 3, -- 13500 Cyc = 450 min = 22.5 kud
[7] = GRVL_CAPA * 5 * 5 * 5, -- 104 kud
[9] = GRVL_CAPA * 7 * 7 * 7, -- 286 kuh
[11] = GRVL_CAPA * 9 * 9 * 9, -- 610 kuh
[13] = GRVL_CAPA * 11 * 11 * 11, -- 1112 kuh
}
local DOWN = 5
local PWR_NEEDED = 5
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: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: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 cooler_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", S("TA4 Heat Exchanger")) .. "]" ..
"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 can_start(pos, nvm)
-- Used as cooler for the collider?
if heatexchanger1_cmnd(pos, "detector") then
if power.power_available(pos, Cable, DOWN) then
nvm.used_as_cooler = true
return true
else
return S("No power")
end
end
-- Used as heat exchanger
local netID = networks.determine_netID(pos, Cable, DOWN)
if heatexchanger1_cmnd(pos, "netID") ~= netID then
return S("Power network connection error")
end
local diameter = heatexchanger1_cmnd(pos, "diameter")
if diameter then
nvm.capa_max = PWR_CAPA[tonumber(diameter)] or 0
if nvm.capa_max ~= 0 then
nvm.capa = math.min(nvm.capa or 0, nvm.capa_max)
local owner = M(pos):get_string("owner") or ""
return heatexchanger1_cmnd(pos, "volume", owner)
else
return S("wrong storage diameter") .. ": " .. diameter
end
else
return S("inlet/pipe error")
end
return S("did you check the plan?")
end
local function start_node(pos, nvm)
if nvm.used_as_cooler then
play_sound(pos)
else
nvm.win_pos = heatexchanger1_cmnd(pos, "window")
power.start_storage_calc(pos, Cable, DOWN)
play_sound(pos)
heatexchanger1_cmnd(pos, "start")
end
end
local function stop_node(pos, nvm)
if nvm.used_as_cooler then
stop_sound(pos)
else
power.start_storage_calc(pos, Cable, DOWN)
stop_sound(pos)
heatexchanger1_cmnd(pos, "stop")
end
end
local function formspec(self, pos, nvm)
local data
if nvm.used_as_cooler then
return cooler_formspec(self, pos, nvm)
end
if techage.is_running(nvm) then
data = power.get_network_data(pos, Cable, DOWN)
end
return techage.storage_formspec(self, pos, nvm, S("TA4 Heat Exchanger"), data, nvm.capa, nvm.capa_max)
end
local function glowing(pos, nvm, should_glow)
if nvm.win_pos then
if should_glow then
swap_node(nvm.win_pos, "techage:glow_gravel")
else
swap_node(nvm.win_pos, "default:gravel")
end
end
end
local function check_TES_integrity(pos, nvm)
nvm.ticks = (nvm.ticks or 0) + 1
if (nvm.ticks % 5) == 0 then -- every 10 sec
if techage.is_running(nvm) then
glowing(pos, nvm, (nvm.capa or 0) / (nvm.capa_max or 1) > 0.8)
end
end
if (nvm.ticks % 30) == 0 then -- every minute
return heatexchanger1_cmnd(pos, "volume")
elseif (nvm.ticks % 30) == 10 then -- every minute
return heatexchanger1_cmnd(pos, "diameter") ~= nil or S("inlet/pipe error")
elseif (nvm.ticks % 30) == 20 then -- every minute
return heatexchanger3_cmnd(pos, "diameter") ~= nil or S("inlet/pipe error")
end
local netID = networks.determine_netID(pos, Cable, DOWN)
if heatexchanger1_cmnd(pos, "netID") ~= netID then
if nvm.check_once_again then
nvm.check_once_again = false
return true
else
return S("Power network connection error")
end
end
nvm.check_once_again = true
return true
end
local State = techage.NodeStates:new({
node_name_passive = "techage:heatexchanger2",
cycle_time = CYCLE_TIME,
infotext_name = S("TA4 Heat Exchanger"),
standby_ticks = 0,
can_start = can_start,
start_node = start_node,
stop_node = stop_node,
formspec_func = formspec,
})
local function cooler_timer(pos, nvm)
local err = false
if power.consume_power(pos, Cable, DOWN, PWR_NEEDED) ~= PWR_NEEDED then
State:fault(pos, nvm, "No power")
stop_sound(pos)
return true
end
-- Cyclically check pipe connections
nvm.ticks = (nvm.ticks or 0) + 1
if (nvm.ticks % 5) == 0 then -- every 10 s
err = heatexchanger1_cmnd(pos, "detector") ~= true
elseif (nvm.ticks % 5) == 1 then -- every 10 s
err = heatexchanger3_cmnd(pos, "detector") ~= true
elseif (nvm.ticks % 5) == 2 then -- every 10 s
err = heatexchanger1_cmnd(pos, "cooler") ~= true
elseif (nvm.ticks % 5) == 3 then -- every 10 s
err = heatexchanger3_cmnd(pos, "cooler") ~= true
end
if err then
State:fault(pos, nvm, "Pipe connection error")
stop_sound(pos)
end
return true
end
local function node_timer(pos, elapsed)
local nvm = techage.get_nvm(pos)
if nvm.used_as_cooler then
cooler_timer(pos, nvm)
return true
end
local res = check_TES_integrity(pos, nvm)
if res ~= true then
State:fault(pos, nvm, res)
heatexchanger1_cmnd(pos, "stop")
power.start_storage_calc(pos, Cable, DOWN)
end
if techage.is_running(nvm) then
local capa = power.get_storage_load(pos, Cable, DOWN, nvm.capa_max) or 0
if capa > 0 then
nvm.capa = capa
end
end
if techage.is_activeformspec(pos) then
M(pos):set_string("formspec", formspec(State, pos, nvm))
end
return true
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:heatexchanger1") then
return true
end
local meta = M(pos)
local nvm = techage.get_nvm(pos)
local own_num = techage.add_node(pos, "techage:heatexchanger1")
meta:set_string("owner", placer:get_player_name())
meta:set_string("infotext", S("TA4 Heat Exchanger")..": "..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
local function get_storage_data(pos, outdir, tlib2)
local nvm = techage.get_nvm(pos)
nvm.capa_max = nvm.capa_max or 1
if techage.is_running(nvm) then
return {level = (nvm.capa or 0) / nvm.capa_max, capa = nvm.capa_max}
end
end
-- Middle node with the formspec from the bottom node
minetest.register_node("techage:heatexchanger2", {
description = S("TA4 Heat Exchanger 2"),
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_appl_tes_core.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:heatexchanger2"}, Cable, "sto", {"D"})
techage.register_node({"techage: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 == "load" then
return techage.power.percent(nvm.capa_max, nvm.capa)
elseif topic == "on" then
State:start(pos, nvm)
return true
elseif topic == "off" then
State:stop(pos, nvm)
return true
else
return "unsupported"
end
end,
on_beduino_receive_cmnd = function(pos, src, topic, payload)
local nvm = techage.get_nvm(pos)
if topic == 1 and payload[1] == 1 then
State:start(pos, nvm)
return 0
elseif topic == 1 and payload[1] == 0 then
State:stop(pos, nvm)
return 0
else
return 2, ""
end
end,
on_beduino_request_data = function(pos, src, topic, payload)
local nvm = techage.get_nvm(pos)
if topic == 128 then
return 0, techage.get_node_lvm(pos).name
elseif topic == 129 then -- State
if techage.is_running(nvm) then
return 0, {techage.RUNNING}
else
return 0, {techage.STOPPED}
end
elseif topic == 135 then -- Delivered Power
local data = power.get_network_data(pos, Cable, DOWN)
return 0, {data.consumed - data.provided}
elseif topic == 134 then -- Tank Load Percent
local value = techage.power.percent(nvm.capa_max, nvm.capa)
return 0, {math.floor(value + 0.5)}
else
return 2, ""
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: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 = S("TA4 Heat Exchanger"),
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:heatexchanger2",
recipe = {
{"default:tin_ingot", "", "default:steel_ingot"},
{"", "techage:ta4_wlanchip", ""},
{"", "techage:baborium_ingot", ""},
},
})
@@ -0,0 +1,103 @@
--[[
TechAge
=======
Copyright (C) 2019-2020 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA4 Heat Exchanger3 (top part)
]]--
-- for lazy programmers
local M = minetest.get_meta
local S = techage.S
local Pipe = techage.LiquidPipe
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:heatexchanger2") then
return true
end
Pipe:after_place_node(pos)
end
local function after_dig_node(pos, oldnode)
Pipe:after_dig_node(pos)
end
local function cooler_cmnd(pos, topic, payload)
return techage.transfer(pos, "R", topic, payload, Pipe,
{"techage:ta4_collider_cooler"})
end
local function inlet_cmnd(pos, topic, payload)
return techage.transfer(pos, "L", topic, payload, Pipe,
{"techage:ta4_pipe_inlet", "techage:ta4_collider_pipe_inlet"})
end
minetest.register_node("techage:heatexchanger3", {
description = S("TA4 Heat Exchanger 3"),
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta4.png^techage_frame_ta4_top.png",
"techage_hole_ta4.png",
"techage_filling_ta4.png^techage_frameT_ta4.png^techage_appl_hole_pipe.png",
"techage_filling_ta4.png^techage_frameT_ta4.png^techage_appl_hole_pipe.png",
"techage_filling_ta4.png^techage_frameT_ta4.png^techage_appl_ribsT.png",
"techage_filling_ta4.png^techage_frameT_ta4.png^techage_appl_ribsT.png",
},
after_place_node = after_place_node,
after_dig_node = after_dig_node,
networks = {
pipe2 = {},
},
paramtype2 = "facedir",
groups = {crumbly = 2, cracky = 2, snappy = 2},
on_rotate = screwdriver.disallow,
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
Pipe:add_secondary_node_names({"techage:heatexchanger3"})
Pipe:set_valid_sides("techage:heatexchanger3", {"R", "L"})
-- command interface, used by heatexchanger2
techage.register_node({"techage:heatexchanger3"}, {
on_transfer = function(pos, indir, topic, payload)
if topic == "cooler" then
return cooler_cmnd(pos, topic, payload)
else
return inlet_cmnd(pos, topic, payload)
end
end,
})
minetest.register_craft({
output = "techage: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
@@ -0,0 +1,254 @@
--[[
TechAge
=======
Copyright (C) 2019-2021 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA4 Pipe Inlet
]]--
-- for lazy programmers
local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
local S2P = minetest.string_to_pos
local M = minetest.get_meta
local M = minetest.get_meta
local S = techage.S
local Pipe = techage.LiquidPipe
local function after_place_node(pos, placer, itemstack)
Pipe:after_place_node(pos)
end
local function after_dig_node(pos, oldnode, oldmetadata, digger)
Pipe:after_dig_node(pos)
end
minetest.register_node("techage:ta4_pipe_inlet", {
description = S("TA4 Pipe Inlet"),
tiles = {
-- up, down, right, left, back, front
"basic_materials_concrete_block.png",
"basic_materials_concrete_block.png",
"basic_materials_concrete_block.png",
"basic_materials_concrete_block.png",
"basic_materials_concrete_block.png^techage_tes_inlet.png",
"basic_materials_concrete_block.png^techage_tes_inlet.png",
},
after_place_node = after_place_node,
after_dig_node = after_dig_node,
networks = {
pipe2 = {},
},
paramtype2 = "facedir", -- important!
on_rotate = screwdriver.disallow, -- important!
groups = {crumbly = 2, cracky = 2, snappy = 2},
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
Pipe:add_secondary_node_names({"techage:ta4_pipe_inlet"})
Pipe:set_valid_sides("techage:ta4_pipe_inlet", {"F", "B"})
local Numbers = {
shell = {
[2] = 96, -- 5x5x2 + 3x5x2 + 3x3x2 - 2
[3] = 216, -- 7x7x2 + 5x7x2 + 5x5x2 - 2
[4] = 384, -- 9x9x2 + 7x9x2 + 7x7x2 - 2
[5] = 600, -- 11x11x2 + 9x11x2 + 9x9x2 - 2
[6] = 864, -- 13x13x2 + 11x13x2 + 11x11x2 - 2
},
filling = {
[2] = 27, -- 3x3x3
[3] = 125, -- 5x5x5
[4] = 343, -- 7x7x7
[5] = 729, -- 9x9x9
[6] = 1331, -- 11x11x11
}
}
local function get_diameter(pos, in_dir)
local dir = tubelib2.Dir6dToVector[in_dir]
local pos2, node
pos2 = vector.add(pos, vector.multiply(dir, 4))
node = minetest.get_node(pos2)
if node.name == "techage:ta3_pipe_wall_entry" then
return
end
if node.name == "techage:ta4_pipe_inlet" then
return 5
end
pos2 = vector.add(pos, vector.multiply(dir, 6))
node = minetest.get_node(pos2)
if node.name == "techage:ta3_pipe_wall_entry" then
return
end
if node.name == "techage:ta4_pipe_inlet" then
return 7
end
pos2 = vector.add(pos, vector.multiply(dir, 8))
node = minetest.get_node(pos2)
if node.name == "techage:ta3_pipe_wall_entry" then
return
end
if node.name == "techage:ta4_pipe_inlet" then
return 9
end
pos2 = vector.add(pos, vector.multiply(dir, 10))
node = minetest.get_node(pos2)
if node.name == "techage:ta3_pipe_wall_entry" then
return
end
if node.name == "techage:ta4_pipe_inlet" then
return 11
end
pos2 = vector.add(pos, vector.multiply(dir, 12))
node = minetest.get_node(pos2)
if node.name == "techage:ta3_pipe_wall_entry" then
return
end
if node.name == "techage:ta4_pipe_inlet" then
return 13
end
pos2 = vector.add(pos, vector.multiply(dir, 14))
local poses = minetest.find_nodes_in_area(pos, pos2, {"techage:ta4_pipe_inlet"})
if #poses > 1 then
return vector.distance(pos, poses[2]) + 1
end
end
local function check_volume(pos, in_dir, owner)
local diameter = get_diameter(pos, in_dir)
if diameter then
local radius = (diameter - 1) / 2
local dir = tubelib2.Dir6dToVector[in_dir]
local cpos = vector.add(pos, vector.multiply(dir, radius))
-- calculate size
local pos1 = {x = cpos.x - radius, y = cpos.y - radius, z = cpos.z - radius}
local pos2 = {x = cpos.x + radius, y = cpos.y + radius, z = cpos.z + radius}
local _, node_tbl = minetest.find_nodes_in_area(pos1, pos2,
{"default:gravel", "techage:ta4_pipe_inlet",
"basic_materials:concrete_block", "default:obsidian_glass",
"techage:glow_gravel"})
local shell_found = node_tbl["default:obsidian_glass"] + node_tbl["basic_materials:concrete_block"]
local fill_found = node_tbl["default:gravel"] + node_tbl["techage:glow_gravel"]
if node_tbl["default:obsidian_glass"] > 1 then
return S("one window maximum")
end
local errors = {}
if shell_found ~= Numbers.shell[radius] then
local diff = Numbers.shell[radius] - shell_found
local hint = diff > 0
and string.format(" (%d missing)", diff)
or string.format(" (%d too many)", -diff)
if owner and owner ~= "" then
minetest.chat_send_player(owner,
string.format("[Thermal Storage] wrong number of shell nodes%s:\n"..
" need %d, found %d (concrete_block=%d, obsidian_glass=%d)\n"..
" cube size %dx%dx%d at %s",
hint,
Numbers.shell[radius], shell_found,
node_tbl["basic_materials:concrete_block"],
node_tbl["default:obsidian_glass"],
diameter, diameter, diameter,
P2S(pos)))
-- if too many concrete: find misplaced blocks inside the inner region
if diff < 0 then
local r = radius - 1
local inner1 = {x = cpos.x - r, y = cpos.y - r, z = cpos.z - r}
local inner2 = {x = cpos.x + r, y = cpos.y + r, z = cpos.z + r}
local bad = minetest.find_nodes_in_area(inner1, inner2,
{"basic_materials:concrete_block"})
if #bad > 0 then
local pstrs = {}
for _, p in ipairs(bad) do pstrs[#pstrs+1] = P2S(p) end
minetest.chat_send_player(owner,
"[Thermal Storage] misplaced concrete block(s) inside:\n " ..
table.concat(pstrs, "\n "))
end
end
end
errors[#errors+1] = S("wrong number of shell nodes") .. hint ..
(owner and owner ~= "" and " (see chat)" or "")
end
if fill_found ~= Numbers.filling[radius] then
local diff = Numbers.filling[radius] - fill_found
local hint = diff > 0
and string.format(" (%d missing)", diff)
or string.format(" (%d too many)", -diff)
if owner and owner ~= "" then
minetest.chat_send_player(owner,
string.format("[Thermal Storage] wrong number of gravel nodes%s:\n"..
" need %d, found %d (gravel=%d, glow_gravel=%d)\n"..
" cube size %dx%dx%d at %s",
hint,
Numbers.filling[radius], fill_found,
node_tbl["default:gravel"],
node_tbl["techage:glow_gravel"],
diameter-2, diameter-2, diameter-2,
P2S(pos)))
end
errors[#errors+1] = S("wrong number of gravel nodes") .. hint ..
(owner and owner ~= "" and " (see chat)" or "")
end
if #errors > 0 then
return table.concat(errors, ", ")
end
else
return S("wrong diameter (should be 5, 7, or 9)")
end
return true
end
-- provide position behind the obsidian_glass
local function check_window(pos, in_dir)
local diameter = get_diameter(pos, in_dir)
if diameter then
local radius = (diameter - 1) / 2
local dir = tubelib2.Dir6dToVector[in_dir]
local cpos = vector.add(pos, vector.multiply(dir, radius))
-- calculate size
local pos1 = {x = cpos.x - radius, y = cpos.y - radius, z = cpos.z - radius}
local pos2 = {x = cpos.x + radius, y = cpos.y + radius, z = cpos.z + radius}
local poses,_ = minetest.find_nodes_in_area(pos1, pos2, {"default:obsidian_glass"})
if #poses == 1 then
local ndir = vector.direction(poses[1], cpos)
ndir = vector.normalize(ndir)
local npos = vector.add(poses[1], ndir)
return npos
end
end
end
-- for logical communication
techage.register_node({"techage:ta4_pipe_inlet"}, {
on_transfer = function(pos, in_dir, topic, payload)
if topic == "diameter" then
return get_diameter(pos, in_dir)
elseif topic == "volume" then
return check_volume(pos, in_dir, payload)
elseif topic == "window" then
return check_window(pos, in_dir)
end
return false
end
})
minetest.register_craft({
type = 'shapeless',
output = "techage:ta4_pipe_inlet",
recipe = {"basic_materials:concrete_block", "techage:ta4_pipeS"},
})
@@ -0,0 +1,36 @@
--[[
TechAge
=======
Copyright (C) 2019 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA4 Nodes
]]--
-- for lazy programmers
local P = minetest.string_to_pos
local M = minetest.get_meta
local S = techage.S
minetest.register_node("techage:glow_gravel", {
description = S("TechAge Gravel"),
tiles = {{
name = "techage_gravel4.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 0.2,
},
}},
paramtype = "light",
light_source = 8,
groups = {crumbly = 2, falling_node = 1, not_in_creative_inventory = 1},
sounds = default.node_sound_gravel_defaults(),
drop = "",
})
@@ -0,0 +1,165 @@
--[[
TechAge
=======
Copyright (C) 2019-2021 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA4 TES 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:ta4_generator", "techage:ta4_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:ta4_turbine", {
description = S("TA4 Turbine"),
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta4.png^techage_frame_ta4_top.png^techage_appl_hole_pipe.png",
"techage_filling_ta4.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_hole_pipe.png",
"techage_filling_ta4.png^techage_appl_turbine.png^techage_frame_ta4.png^[transformFX",
"techage_filling_ta4.png^techage_appl_turbine.png^techage_frame_ta4.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:ta4_turbine_on", {
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta4.png^techage_frame_ta4_top.png^techage_appl_hole_pipe.png",
"techage_filling_ta4.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_hole_pipe.png",
{
name = "techage_filling4_ta4.png^techage_appl_turbine4.png^techage_frame4_ta4.png^[transformFX",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 0.4,
},
},
{
name = "techage_filling4_ta4.png^techage_appl_turbine4.png^techage_frame4_ta4.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:ta4_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:ta4_turbine", "techage:ta4_turbine_on"})
Pipe:set_valid_sides("techage:ta4_turbine", {"L", "U"})
Pipe:set_valid_sides("techage:ta4_turbine_on", {"L", "U"})
techage.register_node({"techage:ta4_turbine", "techage:ta4_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:ta4_turbine_on")
play_sound(pos)
return generator_cmnd(pos, topic, payload)
elseif topic == "stop" then -- used by heatexchanger1
swap_node(pos, "techage:ta4_turbine")
stop_sound(pos)
return generator_cmnd(pos, topic, payload)
else -- used by heatexchanger1
return generator_cmnd(pos, topic, payload)
end
end,
on_node_load = function(pos, node)
if node.name == "techage:ta4_turbine_on" then
play_sound(pos)
end
end,
})
minetest.register_craft({
output = "techage:ta4_turbine",
recipe = {
{"", "dye:blue", ""},
{"", "techage:turbine", ""},
{"", "techage:ta4_wlanchip", ""},
},
})