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
@@ -0,0 +1,140 @@
--[[
TechAge
=======
Copyright (C) 2019-2021 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA2 Steam Engine Boiler
]]--
-- for lazy programmers
local M = minetest.get_meta
local S = techage.S
local CYCLE_TIME = 4
local WATER_CONSUMPTION = 0.5
local Pipe = techage.SteamPipe
local boiler = techage.boiler
local function steaming(pos, nvm, temp)
if temp >= 80 then
local wc = WATER_CONSUMPTION * (nvm.power_ratio or 1)
nvm.water_level = math.max((nvm.water_level or 0) - wc, 0)
end
end
local function node_timer(pos, elapsed)
local nvm = techage.get_nvm(pos)
local temp = boiler.water_temperature(pos, nvm)
steaming(pos, nvm, temp)
if techage.is_activeformspec(pos) then
M(pos):set_string("formspec", boiler.formspec(pos, nvm))
end
return temp > 20
end
local function after_place_node(pos)
local node = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
if node.name ~= "techage:boiler1" then
minetest.remove_node(pos)
return true
end
end
local function after_dig_node(pos, oldnode)
Pipe:after_dig_node(pos)
techage.del_mem(pos)
end
-- boiler2: Main part, needed as generator
minetest.register_node("techage:boiler2", {
description = S("TA2 Boiler Top"),
tiles = {"techage_boiler2.png"},
drawtype = "mesh",
mesh = "techage_cylinder_09.obj",
selection_box = {
type = "fixed",
fixed = {-10/32, -48/32, -10/32, 10/32, 16/32, 10/32},
},
can_dig = boiler.can_dig,
on_timer = node_timer,
on_rightclick = boiler.on_rightclick,
after_place_node = after_place_node,
after_dig_node = after_dig_node,
on_punch = boiler.on_punch,
paramtype = "light",
groups = {cracky=1},
on_rotate = screwdriver.disallow,
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
Pipe:add_secondary_node_names({"techage:boiler2"})
Pipe:set_valid_sides("techage:boiler2", {"U"})
techage.register_node({"techage:boiler2"}, {
on_transfer = function(pos, in_dir, topic, payload)
if topic == "trigger" then
if minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name ~= "techage:boiler1" then
return 0
end
local nvm = techage.get_nvm(pos)
nvm.fire_trigger = true
if not minetest.get_node_timer(pos):is_started() then
minetest.get_node_timer(pos):start(CYCLE_TIME)
end
if (nvm.temperature or 20) > 80 then
nvm.power_ratio = techage.transfer(pos, 6, "trigger", nil, Pipe, {
"techage:cylinder", "techage:cylinder_on"}) or 0
return nvm.power_ratio
else
return 0
end
end
end,
})
minetest.register_node("techage:boiler1", {
description = S("TA2 Boiler Base"),
tiles = {"techage_boiler.png"},
drawtype = "mesh",
mesh = "techage_cylinder_09.obj",
selection_box = {
type = "fixed",
fixed = {-8/32, -16/32, -8/32, 8/32, 16/32, 8/32},
},
paramtype = "light",
groups = {cracky=1},
on_rotate = screwdriver.disallow,
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
minetest.register_craft({
output = "techage:boiler1",
recipe = {
{"techage:iron_ingot", "", "techage:iron_ingot"},
{"default:bronze_ingot", "", "default:bronze_ingot"},
{"techage:iron_ingot", "default:bronze_ingot", "techage:iron_ingot"},
},
})
minetest.register_craft({
output = "techage:boiler2",
recipe = {
{"techage:iron_ingot", "techage:steam_pipeS", "techage:iron_ingot"},
{"default:bronze_ingot", "", "default:bronze_ingot"},
{"techage:iron_ingot", "", "techage:iron_ingot"},
},
})
@@ -0,0 +1,184 @@
--[[
TechAge
=======
Copyright (C) 2019-2020 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA2 Steam Engine Cylinder
]]--
-- for lazy programmers
local M = minetest.get_meta
local S = techage.S
local Pipe = techage.SteamPipe
local function transfer_flywheel(pos, topic, payload)
return techage.transfer(pos, "R", topic, payload, nil,
{"techage:flywheel", "techage:flywheel_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)
-- Stop any lingering handle first, so newly arrived clients get the fresh sound
if mem.handle then
minetest.sound_stop(mem.handle)
mem.handle = nil
end
mem.handle = minetest.sound_play("techage_steamengine", {
pos = pos,
gain = 0.5,
max_hear_distance = 8,
loop = true})
if mem.handle == -1 then
mem.handle = nil
minetest.after(1, play_sound, pos)
end
end
local function stop_sound(pos)
local mem = techage.get_mem(pos)
if mem.handle then
minetest.sound_stop(mem.handle)
-- Keep handle: on_node_load can re-send stop to clients that came back in range
end
end
local function after_place_node(pos)
Pipe:after_place_node(pos)
end
local function after_dig_node(pos, oldnode)
stop_sound(pos)
Pipe:after_dig_node(pos)
techage.del_mem(pos)
end
local function tubelib2_on_update2(pos, outdir, tlib2, node)
swap_node(pos, "techage:cylinder")
stop_sound(pos)
end
minetest.register_node("techage:cylinder", {
description = S("TA2 Cylinder"),
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta2.png^techage_frame_ta2.png",
"techage_filling_ta2.png^techage_frame_ta2.png",
"techage_filling_ta2.png^techage_appl_open.png^techage_frame_ta2.png",
"techage_filling_ta2.png^techage_frame_ta2.png^techage_steam_hole.png",
"techage_filling_ta2.png^techage_cylinder.png^techage_frame_ta2.png",
"techage_filling_ta2.png^techage_cylinder.png^techage_frame_ta2.png",
},
after_place_node = after_place_node,
after_dig_node = after_dig_node,
tubelib2_on_update2 = tubelib2_on_update2,
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:cylinder_on", {
description = S("TA2 Cylinder"),
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta2.png^techage_frame_ta2.png",
"techage_filling_ta2.png^techage_frame_ta2.png",
"techage_filling_ta2.png^techage_appl_open.png^techage_frame_ta2.png",
"techage_filling_ta2.png^techage_frame_ta2.png^techage_steam_hole.png",
{
name = "techage_filling4_ta2.png^techage_cylinder4.png^techage_frame4_ta2.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 0.4,
},
},
{
name = "techage_filling4_ta2.png^techage_cylinder4.png^techage_frame4_ta2.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 0.4,
},
},
},
tubelib2_on_update2 = tubelib2_on_update2,
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:cylinder", "techage:cylinder_on"})
Pipe:set_valid_sides("techage:cylinder", {"L"})
Pipe:set_valid_sides("techage:cylinder_on", {"L"})
techage.register_node({"techage:cylinder", "techage:cylinder_on"}, {
on_transfer = function(pos, in_dir, topic, payload)
local nvm = techage.get_nvm(pos)
if topic == "trigger" then -- used by firebox
local power = transfer_flywheel(pos, topic, payload)
if not power or power <= 0 and nvm.running then
swap_node(pos, "techage:cylinder")
stop_sound(pos)
nvm.running = false
return 0
end
return power
elseif topic == "start" then -- used by flywheel
swap_node(pos, "techage:cylinder_on")
play_sound(pos)
nvm.running = true
return true
elseif topic == "stop" then -- used by flywheel
swap_node(pos, "techage:cylinder")
stop_sound(pos)
nvm.running = false
return true
end
end,
on_node_load = function(pos, node)
--print("on_node_load", node.name)
if node.name == "techage:cylinder_on" then
play_sound(pos) -- stops lingering handle and restarts fresh
else
stop_sound(pos) -- re-send stop to clients that came back in range
end
end,
})
minetest.register_craft({
output = "techage:cylinder",
recipe = {
{"basic_materials:steel_bar", "techage:iron_ingot", "default:wood"},
{"techage:steam_pipeS", "basic_materials:gear_steel", ""},
{"default:wood", "techage:iron_ingot", "basic_materials:steel_bar"},
},
})
@@ -0,0 +1,172 @@
--[[
TechAge
=======
Copyright (C) 2019 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA2 Steam Engine Firebox
]]--
-- for lazy programmers
local P = minetest.string_to_pos
local M = minetest.get_meta
local S = techage.S
local firebox = techage.firebox
local CYCLE_TIME = 2
local BURN_CYCLE_FACTOR = 0.8
local function node_timer(pos, elapsed)
local nvm = techage.get_nvm(pos)
if nvm.running then
local power = techage.transfer(
{x=pos.x, y=pos.y+2, z=pos.z},
nil, -- outdir
"trigger", -- topic
nil, -- payload
nil, -- network
{"techage:boiler2"} -- nodenames
)
nvm.burn_cycles = (nvm.burn_cycles or 0) - math.max((power or 0.1), 0.1)
if nvm.burn_cycles <= 0 then
local taken = firebox.get_fuel(pos)
if taken then
nvm.burn_cycles = (firebox.Burntime[taken:get_name()] or 1) / CYCLE_TIME * BURN_CYCLE_FACTOR
nvm.burn_cycles_total = nvm.burn_cycles
else
nvm.running = false
firebox.swap_node(pos, "techage:firebox")
M(pos):set_string("formspec", firebox.formspec(nvm))
return false
end
end
if techage.is_activeformspec(pos) then
M(pos):set_string("formspec", firebox.formspec(nvm))
end
return true
end
end
minetest.register_node("techage:firebox", {
description = S("TA2 Firebox"),
tiles = {
-- up, down, right, left, back, front
"techage_firebox.png^techage_appl_open.png^techage_frame_ta2.png",
"techage_firebox.png^techage_frame_ta2.png",
"techage_firebox.png^techage_frame_ta2.png",
"techage_firebox.png^techage_frame_ta2.png",
"techage_firebox.png^techage_frame_ta2.png",
"techage_firebox.png^techage_appl_firehole.png^techage_frame_ta2.png",
},
paramtype2 = "facedir",
on_rotate = screwdriver.disallow,
groups = {cracky=2},
is_ground_content = false,
sounds = default.node_sound_stone_defaults(),
on_timer = node_timer,
can_dig = firebox.can_dig,
allow_metadata_inventory_put = firebox.allow_metadata_inventory_put,
allow_metadata_inventory_take = firebox.allow_metadata_inventory_take,
on_rightclick = firebox.on_rightclick,
on_construct = function(pos)
local nvm = techage.get_nvm(pos)
nvm.running = false
nvm.burn_cycles = 0
local meta = M(pos)
meta:set_string("formspec", firebox.formspec(nvm))
local inv = meta:get_inventory()
inv:set_size('fuel', 1)
end,
on_metadata_inventory_put = function(pos, listname, index, stack, player)
local nvm = techage.get_nvm(pos)
nvm.running = true
-- activate the formspec fire temporarily
nvm.burn_cycles = firebox.Burntime[stack:get_name()] / CYCLE_TIME
nvm.burn_cycles_total = nvm.burn_cycles
M(pos):set_string("formspec", firebox.formspec(nvm))
nvm.burn_cycles = 0
firebox.swap_node(pos, "techage:firebox_on")
minetest.get_node_timer(pos):start(CYCLE_TIME)
end,
})
minetest.register_node("techage:firebox_on", {
description = S("TA2 Firebox"),
tiles = {
-- up, down, right, left, back, front
"techage_firebox.png^techage_frame_ta2.png",
"techage_firebox.png^techage_frame_ta2.png",
"techage_firebox.png^techage_frame_ta2.png",
"techage_firebox.png^techage_frame_ta2.png",
"techage_firebox.png^techage_frame_ta2.png",
{
name = "techage_firebox4.png^techage_appl_firehole4.png^techage_frame4_ta2.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 0.4,
},
},
},
paramtype2 = "facedir",
light_source = 8,
on_rotate = screwdriver.disallow,
groups = {cracky=2, not_in_creative_inventory=1},
is_ground_content = false,
sounds = default.node_sound_stone_defaults(),
drop = "techage:firebox",
on_timer = node_timer,
can_dig = firebox.can_dig,
allow_metadata_inventory_put = firebox.allow_metadata_inventory_put,
allow_metadata_inventory_take = firebox.allow_metadata_inventory_take,
on_receive_fields = firebox.on_receive_fields,
on_rightclick = firebox.on_rightclick,
})
minetest.register_craft({
output = "techage:firebox",
recipe = {
{'default:stone', 'default:stone', 'default:stone'},
{'techage:iron_ingot', '', 'techage:iron_ingot'},
{'default:stone', 'default:stone', 'default:stone'},
},
})
techage.register_node({"techage:firebox", "techage:firebox_on"}, {
on_push_item = function(pos, in_dir, stack)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if firebox.Burntime[stack:get_name()] then
if inv:room_for_item("fuel", stack) then
inv:add_item("fuel", stack)
minetest.get_node_timer(pos):start(CYCLE_TIME)
return true
end
end
return false
end,
})
minetest.register_lbm({
label = "[techage] Steam engine firebox",
name = "techage:steam_engine",
nodenames = {"techage:firebox_on"},
run_at_every_load = true,
action = function(pos, node)
local nvm = techage.get_nvm(pos)
nvm.running = true
minetest.get_node_timer(pos):start(CYCLE_TIME)
end
})
@@ -0,0 +1,239 @@
--[[
TechAge
=======
Copyright (C) 2019-2021 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA2 Steam Engine Flywheel
]]--
-- for lazy programmers
local M = minetest.get_meta
local S = techage.S
local STANDBY_TICKS = 4
local COUNTDOWN_TICKS = 4
local CYCLE_TIME = 2
local PWR_PERF = 25
local Axle = techage.Axle
local power = networks.power
-- Axles texture animation
local function switch_axles(pos, on)
local outdir = M(pos):get_int("outdir")
Axle:switch_tube_line(pos, outdir, on and "on" or "off")
end
local function formspec(self, pos, nvm)
return techage.generator_formspec(self, pos, nvm, S("Flywheel"), nvm.provided, PWR_PERF, true)
end
local function transfer_cylinder(pos, topic, payload)
return techage.transfer(pos, "L", topic, payload, nil,
{"techage:cylinder", "techage:cylinder_on"})
end
local function can_start(pos, nvm, state)
return (nvm.firebox_trigger or 0) > 0 -- by means of firebox
end
local function start_node(pos, nvm, state)
switch_axles(pos, true)
local outdir = M(pos):get_int("outdir")
transfer_cylinder(pos, "start")
power.start_storage_calc(pos, Axle, outdir)
end
local function stop_node(pos, nvm, state)
switch_axles(pos, false)
local outdir = M(pos):get_int("outdir")
nvm.provided = 0
transfer_cylinder(pos, "stop")
power.start_storage_calc(pos, Axle, outdir)
end
local State = techage.NodeStates:new({
node_name_passive = "techage:flywheel",
node_name_active = "techage:flywheel_on",
cycle_time = CYCLE_TIME,
standby_ticks = STANDBY_TICKS,
formspec_func = formspec,
can_start = can_start,
start_node = start_node,
stop_node = stop_node,
})
local function node_timer(pos, elapsed)
local nvm = techage.get_nvm(pos)
nvm.firebox_trigger = (nvm.firebox_trigger or 0) - 1
local running = techage.is_running(nvm)
if running and nvm.firebox_trigger <= 0 then
State:standby(pos, nvm)
stop_node(pos, nvm, State)
elseif not running and nvm.firebox_trigger > 0 then
State:start(pos, nvm)
-- start_node() is called implicit
elseif running then
local outdir = M(pos):get_int("outdir")
nvm.provided = power.provide_power(pos, Axle, outdir, PWR_PERF)
local val = power.get_storage_load(pos, Axle, 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
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, true)
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 after_place_node(pos)
local nvm = techage.get_nvm(pos)
State:node_init(pos, nvm, "")
M(pos):set_int("outdir", networks.side_to_outdir(pos, "R"))
M(pos):set_string("formspec", formspec(State, pos, nvm))
Axle:after_place_node(pos)
end
local function after_dig_node(pos, oldnode)
Axle:after_dig_node(pos)
techage.del_mem(pos)
end
local function get_generator_data(pos, outdir, tlib2)
local nvm = techage.get_nvm(pos)
if techage.is_running(nvm) then
return {level = (nvm.load or 0) / PWR_PERF, perf = PWR_PERF, capa = PWR_PERF * 4}
end
end
minetest.register_node("techage:flywheel", {
description = S("TA2 Flywheel"),
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta2.png^techage_frame_ta2.png",
"techage_filling_ta2.png^techage_frame_ta2.png",
"techage_filling_ta2.png^techage_axle_clutch.png^techage_frame_ta2.png",
"techage_filling_ta2.png^techage_appl_open.png^techage_frame_ta2.png",
"techage_filling_ta2.png^techage_frame_ta2.png^techage_flywheel.png",
"techage_filling_ta2.png^techage_frame_ta2.png^techage_flywheel.png^[transformFX]",
},
on_receive_fields = on_receive_fields,
on_rightclick = on_rightclick,
on_timer = node_timer,
after_place_node = after_place_node,
after_dig_node = after_dig_node,
get_generator_data = get_generator_data,
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:flywheel_on", {
description = S("TA2 Flywheel"),
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta2.png^techage_frame_ta2.png",
"techage_filling_ta2.png^techage_frame_ta2.png",
{
name = "techage_filling4_ta2.png^techage_axle_clutch4.png^techage_frame4_ta2.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 0.6,
},
},
"techage_filling_ta2.png^techage_appl_open.png^techage_frame_ta2.png",
{
name = "techage_filling8_ta2.png^techage_frame8_ta2.png^techage_flywheel8.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 64,
aspect_h = 64,
length = 1.2,
},
},
{
name = "techage_filling8_ta2.png^techage_frame8_ta2.png^techage_flywheel8.png^[transformFX]",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 64,
aspect_h = 64,
length = 1.2,
},
},
},
on_receive_fields = on_receive_fields,
on_rightclick = on_rightclick,
on_timer = node_timer,
after_place_node = after_place_node,
after_dig_node = after_dig_node,
get_generator_data = get_generator_data,
drop = "",
paramtype2 = "facedir",
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:flywheel", "techage:flywheel_on"}, Axle, "gen", {"R"})
techage.register_node({"techage:flywheel", "techage:flywheel_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.firebox_trigger = 3
if techage.is_running(nvm) then
return math.max((nvm.provided or PWR_PERF) / PWR_PERF, 0.1)
else
return 0
end
end
end,
on_node_load = function(pos, node)
State:on_node_load(pos)
end,
})
minetest.register_craft({
output = "techage:flywheel",
recipe = {
{"basic_materials:steel_bar", "dye:red", "default:wood"},
{"", "basic_materials:gear_steel", "techage:axle"},
{"default:wood", "techage:iron_ingot", "basic_materials:steel_bar"},
},
})