2021-05-13 18:24:02 +03:00
|
|
|
--[[
|
|
|
|
|
|
|
|
TechAge
|
|
|
|
=======
|
|
|
|
|
2022-01-06 12:13:18 +03:00
|
|
|
Copyright (C) 2019-2022 Joachim Stolberg
|
2021-05-13 18:24:02 +03:00
|
|
|
|
|
|
|
AGPL v3
|
|
|
|
See LICENSE.txt for more information
|
|
|
|
|
|
|
|
Tube Concentrator
|
|
|
|
|
|
|
|
]]--
|
|
|
|
|
|
|
|
-- for lazy programmers
|
|
|
|
local M = minetest.get_meta
|
|
|
|
local S = techage.S
|
|
|
|
|
|
|
|
local Tube = techage.Tube
|
|
|
|
|
|
|
|
local size = 2/8
|
|
|
|
local Boxes = {
|
|
|
|
{{-size, -size, size, size, size, 0.5 }}, -- z+
|
|
|
|
{{-size, -size, -size, 0.5, size, size}}, -- x+
|
|
|
|
{{-size, -size, -0.5, size, size, size}}, -- z-
|
|
|
|
{{-0.5, -size, -size, size, size, size}}, -- x-
|
|
|
|
{{-size, -0.5, -size, size, size, size}}, -- y-
|
|
|
|
{{-size, -size, -size, size, 0.5, size}}, -- y+
|
|
|
|
}
|
|
|
|
|
2021-06-09 23:09:59 +03:00
|
|
|
local names = networks.register_junction("techage:concentrator", 2/8, Boxes, Tube, {
|
2021-05-13 18:24:02 +03:00
|
|
|
description = S("Tube Concentrator"),
|
|
|
|
tiles = {
|
|
|
|
"techage_tube_junction.png^techage_appl_arrow2.png^[transformR270",
|
|
|
|
"techage_tube_junction.png^techage_appl_arrow2.png^[transformR270",
|
|
|
|
"techage_tube_junction.png^techage_tube_hole.png",
|
|
|
|
"techage_tube_junction.png",
|
|
|
|
"techage_tube_junction.png^techage_appl_arrow2.png^[transformR90",
|
|
|
|
"techage_tube_junction.png^techage_appl_arrow2.png^[transformR270",
|
|
|
|
},
|
|
|
|
paramtype2 = "facedir", -- important!
|
2021-07-29 22:08:44 +03:00
|
|
|
use_texture_alpha = techage.CLIP,
|
2021-05-13 18:24:02 +03:00
|
|
|
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 3, techage_trowel = 1},
|
|
|
|
sounds = default.node_sound_defaults(),
|
|
|
|
|
|
|
|
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
|
|
|
local node = minetest.get_node(pos)
|
2021-06-09 23:09:59 +03:00
|
|
|
local name = "techage:concentrator"..networks.junction_type(pos, Tube, "R", node.param2)
|
2021-05-13 18:24:02 +03:00
|
|
|
minetest.swap_node(pos, {name = name, param2 = node.param2})
|
|
|
|
M(pos):set_int("push_dir", techage.side_to_outdir("R", node.param2))
|
|
|
|
Tube:after_place_node(pos)
|
|
|
|
end,
|
|
|
|
tubelib2_on_update2 = function(pos, dir1, tlib2, node)
|
2021-06-09 23:09:59 +03:00
|
|
|
local name = "techage:concentrator"..networks.junction_type(pos, Tube, "R", node.param2)
|
2021-05-13 18:24:02 +03:00
|
|
|
minetest.swap_node(pos, {name = name, param2 = node.param2})
|
|
|
|
end,
|
2022-01-06 12:13:18 +03:00
|
|
|
ta_rotate_node = function(pos, node, new_param2)
|
|
|
|
Tube:after_dig_node(pos)
|
|
|
|
minetest.swap_node(pos, {name = node.name, param2 = new_param2})
|
|
|
|
Tube:after_place_node(pos)
|
|
|
|
M(pos):set_int("push_dir", techage.side_to_outdir("R", new_param2))
|
|
|
|
end,
|
2021-05-13 18:24:02 +03:00
|
|
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
|
|
|
Tube:after_dig_node(pos)
|
|
|
|
end,
|
2021-05-13 18:52:07 +03:00
|
|
|
}, 27)
|
2021-05-13 18:24:02 +03:00
|
|
|
|
2022-05-07 00:02:22 +03:00
|
|
|
for _, name in ipairs(names) do
|
|
|
|
Tube:set_valid_sides(name, {"B", "R", "F", "L", "D", "U"})
|
|
|
|
end
|
|
|
|
|
2021-05-13 18:24:02 +03:00
|
|
|
techage.register_node(names, {
|
|
|
|
on_push_item = function(pos, in_dir, stack)
|
|
|
|
local push_dir = M(pos):get_int("push_dir")
|
2021-09-14 21:07:35 +03:00
|
|
|
return techage.safe_push_items(pos, push_dir, stack)
|
2021-05-13 18:24:02 +03:00
|
|
|
end,
|
|
|
|
is_pusher = true, -- is a pulling/pushing node
|
2022-01-03 23:40:31 +03:00
|
|
|
})
|
2021-05-13 18:24:02 +03:00
|
|
|
|
2021-06-09 23:09:59 +03:00
|
|
|
names = networks.register_junction("techage:ta4_concentrator", 2/8, Boxes, Tube, {
|
2021-05-13 18:52:07 +03:00
|
|
|
description = S("TA4 Tube Concentrator"),
|
2021-05-13 18:24:02 +03:00
|
|
|
tiles = {
|
|
|
|
"techage_tubeta4_junction.png^techage_appl_arrow2.png^[transformR270",
|
|
|
|
"techage_tubeta4_junction.png^techage_appl_arrow2.png^[transformR270",
|
|
|
|
"techage_tubeta4_junction.png^techage_tube_hole.png",
|
|
|
|
"techage_tubeta4_junction.png",
|
|
|
|
"techage_tubeta4_junction.png^techage_appl_arrow2.png^[transformR90",
|
|
|
|
"techage_tubeta4_junction.png^techage_appl_arrow2.png^[transformR270",
|
|
|
|
},
|
|
|
|
paramtype2 = "facedir", -- important!
|
2021-07-29 22:08:44 +03:00
|
|
|
use_texture_alpha = techage.CLIP,
|
2021-05-13 18:24:02 +03:00
|
|
|
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 3, techage_trowel = 1},
|
|
|
|
sounds = default.node_sound_defaults(),
|
|
|
|
|
|
|
|
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
|
|
|
local node = minetest.get_node(pos)
|
2021-06-09 23:09:59 +03:00
|
|
|
local name = "techage:ta4_concentrator"..networks.junction_type(pos, Tube, "R", node.param2)
|
2021-05-13 18:24:02 +03:00
|
|
|
minetest.swap_node(pos, {name = name, param2 = node.param2})
|
|
|
|
M(pos):set_int("push_dir", techage.side_to_outdir("R", node.param2))
|
|
|
|
Tube:after_place_node(pos)
|
|
|
|
end,
|
|
|
|
tubelib2_on_update2 = function(pos, dir1, tlib2, node)
|
2021-06-09 23:09:59 +03:00
|
|
|
local name = "techage:ta4_concentrator"..networks.junction_type(pos, Tube, "R", node.param2)
|
2021-05-13 18:24:02 +03:00
|
|
|
minetest.swap_node(pos, {name = name, param2 = node.param2})
|
|
|
|
end,
|
2022-01-06 12:13:18 +03:00
|
|
|
ta_rotate_node = function(pos, node, new_param2)
|
|
|
|
Tube:after_dig_node(pos)
|
|
|
|
minetest.swap_node(pos, {name = node.name, param2 = new_param2})
|
|
|
|
Tube:after_place_node(pos)
|
|
|
|
M(pos):set_int("push_dir", techage.side_to_outdir("R", new_param2))
|
|
|
|
end,
|
2021-05-13 18:24:02 +03:00
|
|
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
|
|
|
Tube:after_dig_node(pos)
|
|
|
|
end,
|
2021-05-13 18:52:07 +03:00
|
|
|
}, 27)
|
2021-05-13 18:24:02 +03:00
|
|
|
|
2022-05-07 00:02:22 +03:00
|
|
|
for _, name in ipairs(names) do
|
|
|
|
Tube:set_valid_sides(name, {"B", "R", "F", "L", "D", "U"})
|
|
|
|
end
|
|
|
|
|
2021-05-13 18:24:02 +03:00
|
|
|
techage.register_node(names, {
|
|
|
|
on_push_item = function(pos, in_dir, stack)
|
|
|
|
local push_dir = M(pos):get_int("push_dir")
|
2021-09-14 21:07:35 +03:00
|
|
|
return techage.safe_push_items(pos, push_dir, stack)
|
2021-05-13 18:24:02 +03:00
|
|
|
end,
|
|
|
|
is_pusher = true, -- is a pulling/pushing node
|
2022-01-03 23:40:31 +03:00
|
|
|
})
|
2021-05-13 18:24:02 +03:00
|
|
|
|
|
|
|
|
|
|
|
minetest.register_craft({
|
2021-05-13 18:52:07 +03:00
|
|
|
output = "techage:concentrator27",
|
2021-05-13 18:24:02 +03:00
|
|
|
recipe = {
|
|
|
|
{"", "techage:tubeS", ""},
|
|
|
|
{"techage:tubeS", "", "techage:tubeS"},
|
|
|
|
{"", "techage:tubeS", ""},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
2021-05-13 18:52:07 +03:00
|
|
|
output = "techage:ta4_concentrator27",
|
2021-05-13 18:24:02 +03:00
|
|
|
recipe = {
|
|
|
|
{"", "techage:ta4_tubeS", ""},
|
2021-05-13 18:52:07 +03:00
|
|
|
{"techage:ta4_tubeS", "", "techage:ta4_tubeS"},
|
|
|
|
{"", "techage:ta4_tubeS", ""},
|
2021-05-13 18:24:02 +03:00
|
|
|
},
|
2022-01-04 21:40:27 +03:00
|
|
|
})
|