mods that hopefully work for a TechAge-based pack

This commit is contained in:
2026-09-09 06:27:51 -06:00
parent 4e6b08d194
commit c27db2a537
6234 changed files with 375578 additions and 0 deletions
+291
View File
@@ -0,0 +1,291 @@
--[[
TechAge
=======
Copyright (C) 2019-2022 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA5 Fusion Reactor Controller
]]--
-- 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 sched = techage.scheduler
local power = networks.power
local control = networks.control
local CYCLE_TIME = 2
local STANDBY_TICKS = 1
local COUNTDOWN_TICKS = 1
local PWR_NEEDED = 400
local EXPECTED_PLASMA_NUM = 56
local EXPECTED_SHELL_NUM = 56
local EXPECTED_MAGNET_NUM = 56
local CALL_RATE1 = 16 -- 2s * 16 = 32s
local CALL_RATE2 = 8 -- 2s * 8 = 16s
local DESCRIPTION = S("TA5 Fusion Reactor Controller")
local EX_POINTS = 60
local function count_trues(t)
local cnt = 0
for _,v in ipairs(t) do
if v then
cnt = cnt + 1
end
end
return cnt
end
local function nucleus(t)
t = techage.tbl_filter(t, function(v, k, t) return type(v) == "table" end)
if #t == 4 then
if vector.equals(t[1], t[2]) and vector.equals(t[3], t[4]) then
return true
end
end
return S("Nucleus detection error")
end
local tSched = {}
sched.register(tSched, CALL_RATE1, 0, function(pos, outdir)
local resp = control.request(pos, Cable, outdir, "con", "connect")
local cnt = count_trues(resp)
if cnt ~= EXPECTED_MAGNET_NUM then
return S("Magnet detection error\n(@1% found / 100% expected)", math.floor(cnt* 100 / EXPECTED_MAGNET_NUM))
end
return true
end)
sched.register(tSched, CALL_RATE1, 1, function(pos, outdir)
local resp = control.request(pos, Cable, outdir, "con", "test_plasma")
local cnt = count_trues(resp)
if cnt ~= EXPECTED_PLASMA_NUM then
return S("Plasma ring shape error\n(@1% found / 100% expected)", math.floor(cnt * 100 / EXPECTED_PLASMA_NUM))
end
return true
end)
sched.register(tSched, CALL_RATE1, 2, function(pos, outdir)
local resp = control.request(pos, Cable, outdir, "con", "test_shell")
local cnt = count_trues(resp)
if cnt ~= EXPECTED_SHELL_NUM then
return S("Shell shape error\n(@1 of @2 magnets OK)", cnt, EXPECTED_SHELL_NUM)
end
return true
end)
sched.register(tSched, CALL_RATE1, 3, function(pos, outdir)
local resp = control.request(pos, Cable, outdir, "con", "test_nucleus")
return nucleus(resp)
end)
sched.register(tSched, CALL_RATE2, 4, function(pos, outdir)
local resp = control.request(pos, Cable, outdir, "con", "inc_power")
local cnt = count_trues(resp)
--print("inc_power", cnt)
if cnt < 52 then
return S("Cooling failed\n(@1 found / @2 expected)", cnt, 52)
end
return true
end)
local function can_start(pos, nvm)
local outdir = networks.side_to_outdir(pos, "L")
if not power.power_available(pos, Cable, outdir) then
return S("No power")
end
outdir = networks.side_to_outdir(pos, "R")
control.request(pos, Cable, outdir, "con", "rst_power")
for i = 0,4 do
local res = tSched[i](pos, outdir)
if res ~= true then return res end
end
return true
end
local function start_node(pos, nvm)
sched.init(pos)
local outdir = networks.side_to_outdir(pos, "R")
control.send(pos, Cable, outdir, "con", "on")
sched.init(pos)
end
local function stop_node(pos, nvm)
local outdir = networks.side_to_outdir(pos, "R")
control.send(pos, Cable, outdir, "con", "off")
end
local function formspec(self, pos, nvm)
return "size[5,3]"..
"box[0,-0.1;4.8,0.5;#c6e8ff]" ..
"label[0.2,-0.1;" .. minetest.colorize( "#000000", DESCRIPTION) .. "]" ..
"image_button[2,1.5;1,1;".. self:get_state_button_image(nvm) ..";state_button;]"..
"tooltip[2,1.5;1,1;"..self:get_state_tooltip(nvm).."]"
end
local State = techage.NodeStates:new({
node_name_passive = "techage:ta5_fr_controller_pas",
node_name_active = "techage:ta5_fr_controller_act",
cycle_time = CYCLE_TIME,
infotext_name = DESCRIPTION,
standby_ticks = STANDBY_TICKS,
can_start = can_start,
start_node = start_node,
stop_node = stop_node,
formspec_func = formspec,
})
local function after_place_node(pos, placer, itemstack)
local nvm = techage.get_nvm(pos)
local meta = M(pos)
local own_num = techage.add_node(pos, "techage:ta5_fr_controller_pas")
State:node_init(pos, nvm, own_num)
meta:set_string("owner", placer:get_player_name())
Cable:after_place_node(pos)
end
local function consume_power(pos, nvm, outdir)
if techage.needs_power(nvm) then
local taken = power.consume_power(pos, Cable, outdir, PWR_NEEDED)
if techage.is_running(nvm) then
if taken < PWR_NEEDED then
State:nopower(pos, nvm, "No power")
stop_node(pos, nvm)
else
return true -- keep running
end
end
end
end
local function node_timer(pos)
local nvm = techage.get_nvm(pos)
local outdir = networks.side_to_outdir(pos, "L")
if consume_power(pos, nvm, outdir) then
local resp = sched.get(pos, tSched, function()
return true end)(pos, networks.Flip[outdir])
if resp ~= true then
State:fault(pos, nvm, resp)
stop_node(pos, nvm)
else
State:keep_running(pos, nvm, COUNTDOWN_TICKS)
end
end
return State:is_active(nvm)
end
local function after_dig_node(pos, oldnode, oldmetadata)
Cable:after_dig_node(pos)
techage.remove_node(pos, oldnode, oldmetadata)
techage.del_mem(pos)
end
local function on_receive_fields(pos, formname, fields, player)
if minetest.is_protected(pos, player:get_player_name()) then
return
end
local nvm = techage.get_nvm(pos)
if techage.get_expoints(player) >= EX_POINTS then
State:state_button_event(pos, nvm, fields)
else
State:fault(pos, nvm, S("Ex-points missing (@1 < @2)", techage.get_expoints(player), EX_POINTS))
M(pos):set_string("formspec", formspec(State, pos, nvm))
end
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_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_appl_plasma.png^techage_frame_ta5.png",
"techage_filling_ta4.png^techage_appl_plasma.png^techage_frame_ta5.png",
},
after_place_node = after_place_node,
on_timer = node_timer,
after_dig_node = after_dig_node,
on_receive_fields = on_receive_fields,
paramtype2 = "facedir",
groups = {choppy=2, cracky=2, crumbly=2},
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
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",
{
name = "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,
},
},
{
name = "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,
on_receive_fields = on_receive_fields,
paramtype2 = "facedir",
groups = {choppy=2, cracky=2, crumbly=2, not_in_creative_inventory=1},
drop = "",
diggable = false,
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
techage.register_node({"techage:ta5_fr_controller_pas", "techage:ta5_fr_controller_act"}, {
on_recv_message = function(pos, src, topic, payload)
return State:on_receive_message(pos, topic, payload)
end,
on_beduino_receive_cmnd = function(pos, src, topic, payload)
return State:on_beduino_receive_cmnd(pos, topic, payload)
end,
on_beduino_request_data = function(pos, src, topic, payload)
return State:on_beduino_request_data(pos, topic, payload)
end,
})
power.register_nodes({"techage:ta5_fr_controller_pas", "techage:ta5_fr_controller_act"}, Cable, "con", {"L", "R"})
minetest.register_craft({
output = "techage:ta5_fr_controller_pas",
recipe = {
{'techage:aluminum', 'basic_materials:gold_wire', 'default:steel_ingot'},
{'techage:electric_cableS', 'techage:ta5_aichip2', 'techage:electric_cableS'},
{'default:steel_ingot', 'default:diamond', 'techage:aluminum'},
},
})
@@ -0,0 +1,331 @@
--[[
TechAge
=======
Copyright (C) 2019-2022 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA5 Gas Pipes
]]--
-- 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 MAX_PIPE_LENGHT = 100
local liquid = networks.liquid
local Pipe = tubelib2.Tube:new({
dirs_to_check = {1,2,3,4,5,6},
max_tube_length = MAX_PIPE_LENGHT,
show_infotext = false,
force_to_use_tubes = false,
tube_type = "pipe3",
primary_node_names = {
"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
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,
})
-- Enable hidden cables
networks.use_metadata(Pipe)
-- Use global callback instead of node related functions
Pipe:register_on_tube_update2(function(pos, outdir, tlib2, node)
liquid.update_network(pos, outdir, tlib2, node)
end)
minetest.register_node("techage:ta5_pipe1S", {
description = S("TA5 Pipe"),
tiles = {
"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)
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_pipe1A", {
description = S("TA5 Pipe"),
tiles = {
"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)
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_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
local size2 = 2/16
local size3 = 13/32
local Boxes = {
{
{-size1, -size1, size1, size1, size1, 0.5 }, -- z+
{-size2, -size2, size3, size2, size2, 0.5 }, -- z+
},
{
{-size1, -size1, -size1, 0.5, size1, size1}, -- x+
{ size3, -size2, -size2, 0.5, size2, size2}, -- x+
},
{
{-size1, -size1, -0.5, size1, size1, size1}, -- z-
{-size2, -size2, -0.5, size2, size2, -size3}, -- z-
},
{
{-0.5, -size1, -size1, size1, size1, size1}, -- x-
{-0.5, -size2, -size2, -size3, size2, size2}, -- x-
},
{
{-size1, -0.5, -size1, size1, size1, size1}, -- y-
{-size2, -0.5, -size2, size2, -size3, size2}, -- y-
},
{
{-size1, -size1, -size1, size1, 0.5, size1}, -- y+
{-size2, size3, -size2, size2, 0.5, size2}, -- y+
}
}
local names1 = networks.register_junction("techage:ta5_junctionpipe1", 1/8, Boxes, Pipe, {
description = S("TA5 Junction Pipe"),
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_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_junctionpipe1" .. 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)
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:ta5_pipe1S 6",
recipe = {
{'', '', "default:steel_ingot"},
{'', 'dye:blue', 'techage:ta4_carbon_fiber'},
{"", '', 'techage:aluminum'},
},
})
minetest.register_craft({
output = "techage:ta5_pipe2S 6",
recipe = {
{'', '', "default:steel_ingot"},
{'', 'dye:green', 'techage:ta4_carbon_fiber'},
{"", '', 'techage:aluminum'},
},
})
minetest.register_craft({
output = "techage:ta5_junctionpipe125 2",
recipe = {
{"", "techage:ta5_pipe1S", ""},
{"techage:ta5_pipe1S", "", "techage:ta5_pipe1S"},
{"", "techage:ta5_pipe1S", ""},
},
})
minetest.register_craft({
output = "techage:ta5_junctionpipe225 2",
recipe = {
{"", "techage:ta5_pipe2S", ""},
{"techage:ta5_pipe2S", "", "techage:ta5_pipe2S"},
{"", "techage:ta5_pipe2S", ""},
},
})
techage.GasPipe = Pipe
@@ -0,0 +1,279 @@
--[[
TechAge
=======
Copyright (C) 2019-2023 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA5 Fusion Reactor Generator
]]--
-- for lazy programmers
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 STANDBY_TICKS = 1
local COUNTDOWN_TICKS = 2
local PWR_PERF = 800
local function formspec(self, pos, nvm)
return techage.generator_formspec(self, pos, nvm, S("TA5 Generator"), nvm.provided, PWR_PERF)
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 can_start(pos, nvm, state)
if nvm.alive_cnt and nvm.alive_cnt > 0 then
return true
end
return S("no steam")
end
local function start_node(pos, nvm)
local meta = M(pos)
nvm.provided = 0
nvm.alive_cnt = 5
techage.evaluate_charge_termination(nvm, meta)
local outdir = meta:get_int("outdir")
power.start_storage_calc(pos, Cable, outdir)
end
local function stop_node(pos, nvm)
nvm.provided = 0
nvm.alive_cnt = 0
local outdir = M(pos):get_int("outdir")
power.start_storage_calc(pos, Cable, outdir)
end
local State = techage.NodeStates:new({
node_name_passive = "techage:ta5_generator",
node_name_active = "techage:ta5_generator_on",
cycle_time = CYCLE_TIME,
standby_ticks = STANDBY_TICKS,
formspec_func = formspec,
infotext_name = S("TA5 Generator"),
can_start = can_start,
start_node = start_node,
stop_node = stop_node,
})
local function on_receive_fields(pos, formname, fields, player)
if minetest.is_protected(pos, player:get_player_name()) then
return
end
local nvm = techage.get_nvm(pos)
State:state_button_event(pos, nvm, fields)
end
local function on_rightclick(pos, node, clicker)
local nvm = techage.get_nvm(pos)
techage.set_activeformspec(pos, clicker)
M(pos):set_string("formspec", formspec(State, pos, nvm))
end
local function get_generator_data(pos, outdir, tlib2)
local nvm = techage.get_nvm(pos)
if (nvm.alive_cnt or 0) > 0 then
return {level = (nvm.load or 0) / PWR_PERF, perf = PWR_PERF, capa = PWR_PERF * 2}
end
end
local function node_timer(pos, elapsed)
local nvm = techage.get_nvm(pos)
local running = techage.is_running(nvm)
nvm.alive_cnt = (nvm.alive_cnt or 0) - 1
local alive = nvm.alive_cnt > 0
if running and not alive then
State:standby(pos, nvm, S("no steam"))
stop_node(pos, nvm, State)
elseif not running and alive then
State:start(pos, nvm)
elseif running then
local meta = M(pos)
local outdir = meta:get_int("outdir")
local tp1 = tonumber(meta:get_string("termpoint1"))
local tp2 = tonumber(meta:get_string("termpoint2"))
nvm.provided = power.provide_power(pos, Cable, outdir, PWR_PERF, tp1, tp2)
local val = power.get_storage_load(pos, Cable, outdir, PWR_PERF)
if val > 0 then
nvm.load = val
end
State:keep_running(pos, nvm, COUNTDOWN_TICKS)
end
if techage.is_activeformspec(pos) then
M(pos):set_string("formspec", formspec(State, pos, nvm))
end
return State:is_active(nvm)
end
minetest.register_node("techage:ta5_generator", {
description = S("TA5 Generator"),
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta4.png^techage_frame_ta5_top.png",
"techage_filling_ta4.png^techage_frame_ta4_bottom.png",
"techage_filling_ta4.png^techage_appl_hole_electric.png^techage_frame_ta5.png",
"techage_filling_ta4.png^techage_appl_open.png^techage_frame_ta5.png",
"techage_filling_ta4.png^techage_frame_ta5.png^techage_appl_generator.png",
"techage_filling_ta4.png^techage_frame_ta5.png^techage_appl_generator.png^[transformFX]",
},
after_place_node = function(pos, placer)
local nvm = techage.get_nvm(pos)
local number = techage.add_node(pos, "techage:ta5_generator")
State:node_init(pos, nvm, number)
M(pos):set_int("outdir", networks.side_to_outdir(pos, "R"))
M(pos):set_string("formspec", formspec(State, pos, nvm))
Cable:after_place_node(pos)
end,
after_dig_node = function(pos, oldnode)
Cable:after_dig_node(pos)
techage.del_mem(pos)
end,
get_generator_data = get_generator_data,
ta4_formspec = techage.generator_settings("ta4", PWR_PERF),
on_receive_fields = on_receive_fields,
on_rightclick = on_rightclick,
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_generator_on", {
description = S("TA5 Generator"),
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta4.png^techage_frame_ta5_top.png",
"techage_filling_ta4.png^techage_frame_ta4_bottom.png",
"techage_filling_ta4.png^techage_appl_hole_electric.png^techage_frame_ta5.png",
"techage_filling_ta4.png^techage_appl_open.png^techage_frame_ta5.png",
{
name = "techage_filling4_ta4.png^techage_appl_generator4.png^techage_frame4_ta5.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_ta5.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 0.3,
},
},
},
get_generator_data = get_generator_data,
ta4_formspec = techage.generator_settings("ta4", PWR_PERF),
on_receive_fields = on_receive_fields,
on_rightclick = on_rightclick,
on_timer = node_timer,
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(),
})
power.register_nodes({"techage:ta5_generator", "techage:ta5_generator_on"}, Cable, "gen", {"R"})
-- controlled by the turbine
techage.register_node({"techage:ta5_generator", "techage:ta5_generator_on"}, {
on_transfer = function(pos, in_dir, topic, payload)
local nvm = techage.get_nvm(pos)
local node = minetest.get_node(pos)
if topic == "trigger" and in_dir == techage.side_to_indir("L", node.param2) then
nvm.alive_cnt = 5
elseif topic == "start" then
--start_node(pos, nvm)
elseif topic == "stop" then
stop_node(pos, nvm)
end
end,
on_recv_message = function(pos, src, topic, payload)
local nvm = techage.get_nvm(pos)
if topic == "delivered" then
return nvm.provided or 0
else
return State:on_receive_message(pos, topic, payload)
end
end,
on_beduino_receive_cmnd = function(pos, src, topic, payload)
return State:on_beduino_receive_cmnd(pos, topic, payload)
end,
on_beduino_request_data = function(pos, src, topic, payload)
local nvm = techage.get_nvm(pos)
if topic == 135 then
return 0, {nvm.provided or 0}
else
return State:on_beduino_request_data(pos, topic, payload)
end
end,
on_node_load = function(pos)
-- Add node number if missing
local number = M(pos):get_string("node_number")
if number == "" then
local nvm = techage.get_nvm(pos)
local number = techage.add_node(pos, "techage:ta5_generator")
State:node_init(pos, nvm, number)
State:start(pos, nvm)
M(pos):set_string("formspec", formspec(State, pos, nvm))
end
end,
})
control.register_nodes({"techage:ta5_generator", "techage:ta5_generator_on"}, {
on_receive = function(pos, tlib2, topic, payload)
end,
on_request = function(pos, tlib2, topic)
if topic == "info" then
local nvm = techage.get_nvm(pos)
local meta = M(pos)
return {
type = S("TA5 Generator"),
number = "-",
running = (nvm.alive_cnt or 0) > 0,
available = PWR_PERF,
provided = nvm.provided or 0,
termpoint = meta:get_string("termpoint"),
}
end
return false
end,
}
)
minetest.register_craft({
output = "techage:ta5_generator",
recipe = {
{"", "dye:red", ""},
{"", "techage:ta4_generator", ""},
{"", "techage:baborium_ingot", ""},
},
})
@@ -0,0 +1,109 @@
--[[
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")
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_pipe_blue" or 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:ta5_pipe1S", "basic_materials:gear_steel", "techage:ta4_pipeS"},
{"", "techage:baborium_ingot", ""},
},
})
@@ -0,0 +1,431 @@
--[[
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 sched = techage.scheduler
local CYCLE_TIME = 2
local PWR_NEEDED = 5
local COUNTDOWN_TICKS = 1
local DOWN = 5 -- dir
local DESCRIPTION = S("TA5 Heat Exchanger 2")
local EXPECT_BLUE = 56
local EXPECT_GREEN = 52
local CALL_RATE1 = 16 -- 2s * 16 = 32s
local CALL_RATE2 = 8 -- 2s * 8 = 16s
local EX_POINTS = 60
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 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 count_trues(t)
local cnt = 0
for _,v in ipairs(t) do
if v then
cnt = cnt + 1
end
end
return cnt
end
local tSched = {}
sched.register(tSched, CALL_RATE1, 0, function(pos)
if not heatexchanger1_cmnd(pos, "turbine") then
return S("Turbine error")
end
return true
end)
sched.register(tSched, CALL_RATE1, 1, function(pos)
if not heatexchanger3_cmnd(pos, "turbine") then
return S("Cooler error")
end
return true
end)
sched.register(tSched, CALL_RATE1, 2, function(pos)
local resp = heatexchanger1_cmnd(pos, "test_pipe_blue")
if type(resp) ~= "table" then
return DESCRIPTION .. S(" Error!")
end
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_pipe_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_RATE1, 4, function(pos)
local resp = heatexchanger1_cmnd(pos, "test_gas_blue")
local cnt = count_trues(resp)
if cnt ~= EXPECT_BLUE then
return S("Blue pipe coolant missing\n(@1 found / @2 expected)", cnt, EXPECT_BLUE)
end
return true
end)
sched.register(tSched, CALL_RATE1, 5, function(pos)
local resp = heatexchanger3_cmnd(pos, "test_gas_green")
local cnt = count_trues(resp)
if cnt ~= EXPECT_GREEN then
return S("Green pipe coolant missing\n(@1 found / @2 expected)", cnt, EXPECT_GREEN)
end
return true
end)
sched.register(tSched, CALL_RATE2, 6, 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)
if not power.power_available(pos, Cable, DOWN) then
return S("No power")
end
heatexchanger3_cmnd(pos, "rst_power")
for i = 0,6 do
local res = tSched[i](pos)
if res ~= true and res ~= 1 then
if res == 0 then
return S("Cooling test failed")
end
return res
end
end
return true
end
local function start_node(pos, nvm)
play_sound(pos)
sched.init(pos)
nvm.temperature = nvm.temperature or 0
local mem = techage.get_mem(pos)
local t = minetest.get_gametime() - (mem.stopped_at or 0)
nvm.temperature = math.max(nvm.temperature - math.floor(t/2), 0)
nvm.temperature = math.min(nvm.temperature, 70)
end
local function stop_node(pos, nvm)
stop_sound(pos)
heatexchanger1_cmnd(pos, "stop")
local mem = techage.get_mem(pos)
mem.stopped_at = minetest.get_gametime()
end
local function temp_indicator (nvm, x, y)
local temp = techage.is_running(nvm) and nvm.temperature or 0
return "image[" .. x .. "," .. y .. ";1,2;techage_form_temp_bg.png^[lowpart:" ..
temp .. ":techage_form_temp_fg.png]" ..
"tooltip[" .. x .. "," .. y .. ";1,2;" .. S("water temperature") .. ";#0C3D32;#FFFFFF]"
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) .. "]" ..
temp_indicator (nvm, 1, 1) ..
"image_button[3.2,1.5;1,1;".. self:get_state_button_image(nvm) ..";state_button;]"..
"tooltip[3.2,1.5;1,1;"..self:get_state_tooltip(nvm).."]"
end
local State = techage.NodeStates:new({
node_name_passive = "techage:ta5_heatexchanger2",
cycle_time = CYCLE_TIME,
infotext_name = DESCRIPTION,
standby_ticks = 1,
can_start = can_start,
start_node = start_node,
stop_node = stop_node,
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)
State:stop(pos, nvm)
return false
end
if resp == 0 and nvm.temperature == 70 then
heatexchanger1_cmnd(pos, "stop")
elseif nvm.temperature == 80 then
if resp == 1 then
heatexchanger1_cmnd(pos, "start")
local owner = M(pos):get_string("owner")
minetest.log("action", "[techage] " .. owner .. " starts the TA5 Fusion Reactor at " .. P2S(pos))
else
heatexchanger1_cmnd(pos, "trigger")
end
elseif nvm.temperature > 80 then
heatexchanger1_cmnd(pos, "trigger")
end
return true
end
local function consume_power(pos, nvm)
if techage.needs_power(nvm) then
local taken = power.consume_power(pos, Cable, DOWN, PWR_NEEDED)
if techage.is_running(nvm) then
if taken < PWR_NEEDED then
State:nopower(pos, nvm, S("No power"))
stop_sound(pos)
heatexchanger1_cmnd(pos, "stop")
else
return true -- keep running
end
end
end
end
local function node_timer(pos, elapsed)
local nvm = techage.get_nvm(pos)
nvm.temperature = nvm.temperature or 0
--print("node_timer", nvm.temperature)
if consume_power(pos, nvm) then
if steam_management(pos, nvm) then
State:keep_running(pos, nvm, COUNTDOWN_TICKS)
end
end
if techage.is_activeformspec(pos) then
M(pos):set_string("formspec", formspec(State, pos, nvm))
end
return State:is_active(nvm) or nvm.temperature > 0
end
local function can_dig(pos, player)
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
if techage.get_expoints(player) >= EX_POINTS then
local nvm = techage.get_nvm(pos)
State:state_button_event(pos, nvm, fields)
--M(pos):set_string("formspec", formspec(State, pos, nvm))
end
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,
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
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
start_node(pos, techage.get_nvm(pos))
return 0
elseif topic == 1 and payload[1] == 0 then
stop_node(pos, techage.get_nvm(pos))
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}
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
State:start(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:ta5_aichip2", ""},
{"", "techage:baborium_ingot", ""},
},
})
@@ -0,0 +1,106 @@
--[[
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")
return control.request(pos, Pipe3, outdir, "tank", topic)
end
minetest.register_node("techage:ta5_heatexchanger3", {
description = S("TA5 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:red", "default:steel_ingot"},
{"techage:ta5_pipe2S", "basic_materials:gear_steel", "techage:ta4_pipeS"},
{"", "techage:baborium_ingot", ""},
},
})
techage.orientate_node = orientate_node
@@ -0,0 +1,271 @@
--[[
TechAge
=======
Copyright (C) 2019-2022 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA5 Fusion Reactor Magnet
]]--
-- 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.GasPipe
local power = networks.power
local liquid = networks.liquid
local control = networks.control
local CAPACITY = 6
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_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_steel_tiles_side.png^[transformR180]",
"techage_collider_magnet.png^techage_appl_hole_electric.png",
"techage_steel_tiles.png",
},
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,
paramtype2 = "facedir",
groups = {choppy=2, cracky=2, crumbly=2},
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
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_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_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)
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,
paramtype2 = "facedir",
groups = {choppy=2, cracky=2, crumbly=2},
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
power.register_nodes({"techage:ta5_magnet1"}, Cable, "con", {"B"})
liquid.register_nodes({"techage:ta5_magnet1", "techage:ta5_magnet2"}, Pipe, "tank", {"U", "D"}, {
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,
})
local function check_plasma(pos, param2)
local pos1 = networks.get_relpos(pos, "F", param2)
local node = minetest.get_node(pos1) or {}
return node.name == "air"
end
local function swap_plasma(pos, name, param2)
local pos1 = networks.get_relpos(pos, "F", param2)
minetest.swap_node(pos1, {name = name, param2 = param2})
end
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
return cnt == 6
end
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_receive(pos, tlib2, topic, payload)
--print("on_receive", topic)
local nvm = techage.get_nvm(pos)
if topic == "on" then
nvm.running = true
elseif topic == "off" then
nvm.running = false
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 nvm = techage.get_nvm(pos)
nvm.liquid = nvm.liquid or {}
nvm.liquid.amount = nvm.liquid.amount or 0
if tlib2 == Cable then
if topic == "connect" then
return true
elseif topic == "inc_power" then
return inc_power(nvm)
elseif topic == "test_plasma" then
local node = minetest.get_node(pos) or {}
return check_plasma(pos, node.param2)
elseif topic == "test_shell" then
local node = minetest.get_node(pos) or {}
return check_shell(pos, node.param2)
elseif topic == "test_nucleus" then
local node = minetest.get_node(pos) or {}
return check_nucleus(pos, node.param2)
elseif topic == "no_gas" then
nvm.liquid.amount = 0
return true
end
else -- Pipe
if topic == "dec_power" then
return dec_power(nvm)
elseif topic == "test_pipe_blue" then
nvm.test_pipe = true
return true
elseif topic == "test_pipe_green" then
local res = nvm.test_pipe
nvm.test_pipe = false
return res
elseif topic == "test_gas_blue" then
nvm.has_gas = true
return nvm.liquid.amount == CAPACITY
elseif topic == "test_gas_green" then
local res = nvm.has_gas
nvm.has_gas = false
return res
end
end
if topic == "rst_power" then
return rst_power(nvm)
end
return false
end
control.register_nodes({"techage:ta5_magnet1", "techage:ta5_magnet2"}, {
on_receive = on_receive,
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 2",
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'},
{'', '', ''},
},
})
@@ -0,0 +1,59 @@
--[[
TechAge
=======
Copyright (C) 2019-2022 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA5 Fusion Reactor Shell
]]--
-- for lazy programmers
local S2P = minetest.string_to_pos
local P2S = minetest.pos_to_string
local M = minetest.get_meta
local S = techage.S
minetest.register_node("techage:ta5_fr_shell", {
description = S("TA5 Fusion Reactor Shell"),
tiles = {
"techage_reactor_shell.png",
},
paramtype2 = "facedir",
paramtype = "light",
groups = {choppy=2, cracky=2, crumbly=2},
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
minetest.register_node("techage:ta5_fr_nucleus", {
description = S("TA5 Fusion Reactor Nucleus"),
tiles = {
"techage_reactor_shell.png^techage_collider_detector_core.png",
},
paramtype2 = "facedir",
paramtype = "light",
groups = {choppy=2, cracky=2, crumbly=2},
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
techage.furnace.register_recipe({
output = "techage:ta5_fr_shell 3",
recipe = {'techage:ta4_colliderblock', 'techage:ta4_colliderblock', "techage:graphite_powder"},
time = 24,
})
minetest.register_craft({
output = "techage:ta5_fr_nucleus",
recipe = {
{"", "techage:ta5_aichip2", ""},
{"techage:electric_cableS", "techage:cylinder_large_hydrogen", "techage:ta3_valve_open"},
{"", "techage:ta5_fr_shell", ""},
},
})
@@ -0,0 +1,250 @@
--[[
TechAge
=======
Copyright (C) 2019-2022 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA5 Pump
]]--
local S2P = minetest.string_to_pos
local P2S = minetest.pos_to_string
local M = minetest.get_meta
local S = techage.S
local Pipe2 = techage.LiquidPipe
local Pipe3 = techage.GasPipe
local liquid = networks.liquid
local Flip = networks.Flip
local STANDBY_TICKS = 16
local COUNTDOWN_TICKS = 4
local CYCLE_TIME = 2
local CAPA = 4
local function get_liquid_amount(pos)
local outdir = M(pos):get_int("outdir")
local netw = networks.get_network_table(pos, Pipe3, outdir)
if netw and netw["tank"] then
local amount = 0
local capa = 0
for _, item in ipairs(netw["tank"]) do
local node = minetest.get_node(item.pos)
local ndef = minetest.registered_nodes[node.name]
if ndef and ndef.liquid then
local nvm = techage.get_nvm(item.pos)
amount = amount + (nvm.liquid and nvm.liquid.amount or 0)
capa = capa + (ndef.liquid.capa or 0)
end
end
return amount .. " / " .. capa
end
return ""
end
local WRENCH_MENU = {{
type = "output",
name = "flowrate",
label = S("Total flow rate"),
tooltip = S("Total flow rate in liquid units"),
},{
type = "dropdown",
choices = "normal,reverse",
name = "operation",
label = S("Operation"),
tooltip = S("Pump direction"),
values = {0, 1},
default = "1",
},{
type = "output",
name = "liquid_amount",
label = S("Coolant"),
tooltip = S("Amount of isobutane in the cooling system"),
on_value = get_liquid_amount,
}}
local State = techage.NodeStates:new({
node_name_passive = "techage:ta5_pump",
node_name_active = "techage:ta5_pump_on",
infotext_name = S("TA5 Pump"),
cycle_time = CYCLE_TIME,
standby_ticks = STANDBY_TICKS,
})
local function pumping(pos, nvm)
local outdir = M(pos):get_int("outdir")
local reverse = M(pos):get_int("operation")
if reverse == 1 then
local taken, name = liquid.take(pos, Pipe3, outdir, nil, CAPA)
if taken > 0 then
local leftover = liquid.put(pos, Pipe2, Flip[outdir], name, taken)
if leftover and leftover > 0 then
liquid.untake(pos, Pipe3, outdir, name, leftover)
if leftover == taken then
State:blocked(pos, nvm, S("blocked: destination full or not connected"))
return 0
end
State:keep_running(pos, nvm, COUNTDOWN_TICKS)
return taken - leftover
end
State:keep_running(pos, nvm, COUNTDOWN_TICKS)
return taken
end
else
local taken, name = liquid.take(pos, Pipe2, Flip[outdir], nil, CAPA)
if taken > 0 then
local leftover = liquid.put(pos, Pipe3, outdir, name, taken)
if leftover and leftover > 0 then
liquid.untake(pos, Pipe2, Flip[outdir], name, leftover)
if leftover == taken then
State:blocked(pos, nvm, S("blocked: destination full or not connected"))
return 0
end
State:keep_running(pos, nvm, COUNTDOWN_TICKS)
return taken - leftover
end
State:keep_running(pos, nvm, COUNTDOWN_TICKS)
return taken
end
end
State:idle(pos, nvm)
return 0
end
local function after_place_node(pos, placer)
local nvm = techage.get_nvm(pos)
local number = techage.add_node(pos, "techage:ta5_pump")
State:node_init(pos, nvm, number)
M(pos):set_int("outdir", networks.side_to_outdir(pos, "R"))
Pipe2:after_place_node(pos)
Pipe3:after_place_node(pos)
end
local function node_timer(pos, elapsed)
local nvm = techage.get_nvm(pos)
nvm.flowrate = (nvm.flowrate or 0) + pumping(pos, nvm)
return State:is_active(nvm)
end
local function on_rightclick(pos, node, clicker)
if minetest.is_protected(pos, clicker:get_player_name()) then
return
end
local nvm = techage.get_nvm(pos)
if node.name == "techage:ta5_pump" then
State:start(pos, nvm)
elseif node.name == "techage:ta5_pump_on" then
State:stop(pos, nvm)
end
end
local function after_dig_node(pos, oldnode, oldmetadata, digger)
Pipe2:after_dig_node(pos)
Pipe3:after_dig_node(pos)
techage.del_mem(pos)
end
local tiles_pas = {
-- 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_appl_hole_ta5_pipe2.png^techage_frame_ta5.png",
"techage_filling_ta4.png^techage_appl_hole_pipe.png^techage_frame_ta5.png",
"techage_filling_ta4.png^techage_appl_pump.png^techage_frame_ta5.png^[transformFX",
"techage_filling_ta4.png^techage_appl_pump.png^techage_frame_ta5.png",
}
local tiles_act = {
-- 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_appl_hole_ta5_pipe2.png^techage_frame_ta5.png",
"techage_filling_ta4.png^techage_appl_hole_pipe.png^techage_frame_ta5.png",
{
name = "techage_filling8_ta4.png^techage_appl_pump8.png^techage_frame8_ta5.png^[transformFX",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 2.0,
},
},
{
name = "techage_filling8_ta4.png^techage_appl_pump8.png^techage_frame8_ta5.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 2.0,
},
},
}
minetest.register_node("techage:ta5_pump", {
description = S("TA5 Pump"),
tiles = tiles_pas,
after_place_node = after_place_node,
on_rightclick = on_rightclick,
on_timer = node_timer,
after_dig_node = after_dig_node,
on_rotate = screwdriver.disallow,
paramtype2 = "facedir",
on_rotate = screwdriver.disallow,
groups = {cracky=2},
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
ta4_formspec = WRENCH_MENU,
})
minetest.register_node("techage:ta5_pump_on", {
description = S("TA5 Pump"),
tiles = tiles_act,
--after_place_node = after_place_node4,
on_rightclick = on_rightclick,
on_timer = node_timer,
after_dig_node = after_dig_node,
on_rotate = screwdriver.disallow,
paramtype2 = "facedir",
on_rotate = screwdriver.disallow,
diggable = false,
groups = {not_in_creative_inventory=1},
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
techage.register_node({"techage:ta5_pump", "techage:ta5_pump_on"}, {
on_recv_message = function(pos, src, topic, payload)
return State:on_receive_message(pos, topic, payload)
end,
on_beduino_receive_cmnd = function(pos, src, topic, payload)
return State:on_beduino_receive_cmnd(pos, topic, payload)
end,
on_beduino_request_data = function(pos, src, topic, payload)
return State:on_beduino_request_data(pos, topic, payload)
end,
})
-- Pumps have to provide one output and one input side
liquid.register_nodes({
"techage:ta5_pump", "techage:ta5_pump_on",
}, Pipe2, "pump", {"L"}, {})
liquid.register_nodes({
"techage:ta5_pump", "techage:ta5_pump_on",
}, Pipe3, "pump", {"R"}, {})
minetest.register_craft({
output = "techage:ta5_pump",
recipe = {
{"techage:aluminum", "dye:red", "default:steel_ingot"},
{"techage:ta4_pipeS", "techage:ta5_ceramic_turbine", "techage:ta5_pipe1S"},
{"default:steel_ingot", "basic_materials:motor", "techage:aluminum"},
},
})
@@ -0,0 +1,170 @@
--[[
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^[transformFX",
"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",
{
name = "techage_filling4_ta4.png^techage_appl_turbine4.png^techage_frame4_ta5.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_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"}, {
-- used by heatexchanger1
on_transfer = function(pos, in_dir, topic, payload)
local nvm = techage.get_nvm(pos)
if topic == "trigger" then
return generator_cmnd(pos, topic, payload)
elseif topic == "start" then
swap_node(pos, "techage:ta5_turbine_on")
play_sound(pos)
return generator_cmnd(pos, topic, payload)
elseif topic == "stop" then
swap_node(pos, "techage:ta5_turbine")
stop_sound(pos)
return generator_cmnd(pos, topic, payload)
elseif topic == "turbine" then
return true
else
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:red", ""},
{"", "techage:turbine", ""},
{"", "techage:ta5_ceramic_turbine", ""},
},
})