2019-09-02 23:19:34 +03:00
|
|
|
--[[
|
|
|
|
|
|
|
|
TechAge
|
|
|
|
=======
|
|
|
|
|
2021-06-19 16:06:08 +03:00
|
|
|
Copyright (C) 2019-2021 Joachim Stolberg
|
2019-09-02 23:19:34 +03:00
|
|
|
|
2020-10-19 20:09:17 +03:00
|
|
|
AGPL v3
|
2019-09-02 23:19:34 +03:00
|
|
|
See LICENSE.txt for more information
|
2022-01-03 23:40:31 +03:00
|
|
|
|
2020-02-06 22:51:30 +03:00
|
|
|
TA4 TES Gas Turbine
|
2019-09-02 23:19:34 +03:00
|
|
|
|
|
|
|
]]--
|
|
|
|
|
|
|
|
-- for lazy programmers
|
|
|
|
local M = minetest.get_meta
|
|
|
|
local S = techage.S
|
|
|
|
|
2020-01-31 21:55:10 +03:00
|
|
|
local Pipe = techage.LiquidPipe
|
2019-09-02 23:19:34 +03:00
|
|
|
|
2021-06-19 16:06:08 +03:00
|
|
|
local function generator_cmnd(pos, topic, payload)
|
2022-01-03 23:40:31 +03:00
|
|
|
return techage.transfer(pos, "R", topic, payload, nil,
|
2020-02-06 22:51:30 +03:00
|
|
|
{"techage:ta4_generator", "techage:ta4_generator_on"})
|
|
|
|
end
|
|
|
|
|
2019-09-02 23:19:34 +03:00
|
|
|
local function swap_node(pos, name)
|
2019-10-07 01:09:39 +03:00
|
|
|
local node = techage.get_node_lvm(pos)
|
2019-09-02 23:19:34 +03:00
|
|
|
if node.name == name then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
node.name = name
|
|
|
|
minetest.swap_node(pos, node)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function play_sound(pos)
|
2020-02-02 00:00:58 +03:00
|
|
|
local mem = techage.get_mem(pos)
|
|
|
|
if not mem.handle or mem.handle == -1 then
|
|
|
|
mem.handle = minetest.sound_play("techage_turbine", {
|
2022-01-03 23:40:31 +03:00
|
|
|
pos = pos,
|
2020-02-06 22:51:30 +03:00
|
|
|
gain = 0.4,
|
2020-02-02 00:00:58 +03:00
|
|
|
max_hear_distance = 10,
|
|
|
|
loop = true})
|
|
|
|
if mem.handle == -1 then
|
|
|
|
minetest.after(1, play_sound, pos)
|
|
|
|
end
|
2019-09-02 23:19:34 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function stop_sound(pos)
|
2020-02-02 00:00:58 +03:00
|
|
|
local mem = techage.get_mem(pos)
|
|
|
|
if mem.handle then
|
|
|
|
minetest.sound_stop(mem.handle)
|
|
|
|
mem.handle = nil
|
2019-09-02 23:19:34 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_node("techage:ta4_turbine", {
|
|
|
|
description = S("TA4 Turbine"),
|
|
|
|
tiles = {
|
|
|
|
-- up, down, right, left, back, front
|
2019-11-03 01:39:10 +03:00
|
|
|
"techage_filling_ta4.png^techage_frame_ta4_top.png^techage_appl_hole_pipe.png",
|
2019-09-02 23:19:34 +03:00
|
|
|
"techage_filling_ta4.png^techage_frame_ta4.png",
|
|
|
|
"techage_filling_ta4.png^techage_appl_open.png^techage_frame_ta4.png",
|
2019-11-03 01:39:10 +03:00
|
|
|
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_hole_pipe.png",
|
2023-04-03 20:39:39 +03:00
|
|
|
"techage_filling_ta4.png^techage_appl_turbine.png^techage_frame_ta4.png^[transformFX",
|
2019-09-02 23:19:34 +03:00
|
|
|
"techage_filling_ta4.png^techage_appl_turbine.png^techage_frame_ta4.png",
|
|
|
|
},
|
2022-01-03 23:40:31 +03:00
|
|
|
|
2021-06-19 16:06:08 +03:00
|
|
|
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 = {},
|
|
|
|
},
|
2019-09-02 23:19:34 +03:00
|
|
|
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
|
2019-11-03 01:39:10 +03:00
|
|
|
"techage_filling_ta4.png^techage_frame_ta4_top.png^techage_appl_hole_pipe.png",
|
2019-09-02 23:19:34 +03:00
|
|
|
"techage_filling_ta4.png^techage_frame_ta4.png",
|
|
|
|
"techage_filling_ta4.png^techage_appl_open.png^techage_frame_ta4.png",
|
2019-11-03 01:39:10 +03:00
|
|
|
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_hole_pipe.png",
|
2019-09-02 23:19:34 +03:00
|
|
|
{
|
2023-04-07 11:51:33 +03:00
|
|
|
name = "techage_filling4_ta4.png^techage_appl_turbine4.png^techage_frame4_ta4.png^[transformFX",
|
2019-09-02 23:19:34 +03:00
|
|
|
backface_culling = false,
|
|
|
|
animation = {
|
|
|
|
type = "vertical_frames",
|
|
|
|
aspect_w = 32,
|
|
|
|
aspect_h = 32,
|
|
|
|
length = 0.4,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2023-04-07 11:51:33 +03:00
|
|
|
name = "techage_filling4_ta4.png^techage_appl_turbine4.png^techage_frame4_ta4.png",
|
2019-09-02 23:19:34 +03:00
|
|
|
backface_culling = false,
|
|
|
|
animation = {
|
|
|
|
type = "vertical_frames",
|
|
|
|
aspect_w = 32,
|
|
|
|
aspect_h = 32,
|
|
|
|
length = 0.4,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-01-03 23:40:31 +03:00
|
|
|
|
|
|
|
tubelib2_on_update2 = function(pos, outdir, tlib2, node)
|
2021-06-19 16:06:08 +03:00
|
|
|
swap_node(pos, "techage:ta4_turbine")
|
|
|
|
stop_sound(pos)
|
|
|
|
generator_cmnd(pos, "stop")
|
|
|
|
end,
|
|
|
|
networks = {
|
|
|
|
pipe2 = {},
|
|
|
|
},
|
2019-09-02 23:19:34 +03:00
|
|
|
paramtype2 = "facedir",
|
|
|
|
groups = {not_in_creative_inventory=1},
|
|
|
|
diggable = false,
|
|
|
|
on_rotate = screwdriver.disallow,
|
|
|
|
is_ground_content = false,
|
|
|
|
sounds = default.node_sound_wood_defaults(),
|
|
|
|
})
|
|
|
|
|
2020-02-06 22:51:30 +03:00
|
|
|
Pipe:add_secondary_node_names({"techage:ta4_turbine", "techage:ta4_turbine_on"})
|
2021-06-19 16:06:08 +03:00
|
|
|
Pipe:set_valid_sides("techage:ta4_turbine", {"L", "U"})
|
|
|
|
Pipe:set_valid_sides("techage:ta4_turbine_on", {"L", "U"})
|
2019-09-02 23:19:34 +03:00
|
|
|
|
|
|
|
techage.register_node({"techage:ta4_turbine", "techage:ta4_turbine_on"}, {
|
|
|
|
on_transfer = function(pos, in_dir, topic, payload)
|
2020-01-31 21:55:10 +03:00
|
|
|
local nvm = techage.get_nvm(pos)
|
2021-06-19 16:06:08 +03:00
|
|
|
if topic == "start" then -- used by heatexchanger1
|
2019-09-14 00:01:55 +03:00
|
|
|
swap_node(pos, "techage:ta4_turbine_on")
|
|
|
|
play_sound(pos)
|
2021-06-19 16:06:08 +03:00
|
|
|
return generator_cmnd(pos, topic, payload)
|
|
|
|
elseif topic == "stop" then -- used by heatexchanger1
|
2019-09-02 23:19:34 +03:00
|
|
|
swap_node(pos, "techage:ta4_turbine")
|
|
|
|
stop_sound(pos)
|
2021-06-19 16:06:08 +03:00
|
|
|
return generator_cmnd(pos, topic, payload)
|
|
|
|
else -- used by heatexchanger1
|
|
|
|
return generator_cmnd(pos, topic, payload)
|
2019-09-02 23:19:34 +03:00
|
|
|
end
|
2020-02-06 22:51:30 +03:00
|
|
|
end,
|
|
|
|
on_node_load = function(pos, node)
|
|
|
|
if node.name == "techage:ta4_turbine_on" then
|
|
|
|
play_sound(pos)
|
2022-01-03 23:40:31 +03:00
|
|
|
end
|
2020-02-06 22:51:30 +03:00
|
|
|
end,
|
2019-09-02 23:19:34 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "techage:ta4_turbine",
|
|
|
|
recipe = {
|
2019-09-14 00:01:55 +03:00
|
|
|
{"", "dye:blue", ""},
|
|
|
|
{"", "techage:turbine", ""},
|
|
|
|
{"", "techage:ta4_wlanchip", ""},
|
2019-09-02 23:19:34 +03:00
|
|
|
},
|
|
|
|
})
|