2019-03-02 14:24:48 +03:00
|
|
|
--[[
|
|
|
|
|
|
|
|
TechAge
|
|
|
|
=======
|
|
|
|
|
2020-04-15 23:21:22 +03:00
|
|
|
Copyright (C) 2019-2020 Joachim Stolberg
|
2019-03-02 14:24:48 +03:00
|
|
|
|
2020-10-19 20:09:17 +03:00
|
|
|
AGPL v3
|
2019-03-02 14:24:48 +03:00
|
|
|
See LICENSE.txt for more information
|
2022-01-03 23:40:31 +03:00
|
|
|
|
2019-03-02 14:24:48 +03:00
|
|
|
Tubes based on tubelib2
|
|
|
|
|
|
|
|
]]--
|
|
|
|
|
2021-05-13 18:52:07 +03:00
|
|
|
local S = techage.S
|
2019-03-02 14:24:48 +03:00
|
|
|
|
|
|
|
|
|
|
|
-- used for registered nodes
|
|
|
|
techage.KnownNodes = {
|
|
|
|
["techage:tubeS"] = true,
|
|
|
|
["techage:tubeA"] = true,
|
2020-03-19 00:35:23 +03:00
|
|
|
["techage:ta4_tubeS"] = true,
|
|
|
|
["techage:ta4_tubeA"] = true,
|
2019-03-02 14:24:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
local Tube = tubelib2.Tube:new({
|
|
|
|
-- North, East, South, West, Down, Up
|
|
|
|
dirs_to_check = {1,2,3,4,5,6},
|
2022-01-03 23:40:31 +03:00
|
|
|
max_tube_length = 200,
|
2019-03-02 14:24:48 +03:00
|
|
|
show_infotext = false,
|
2020-04-15 23:21:22 +03:00
|
|
|
primary_node_names = {
|
2022-01-03 23:40:31 +03:00
|
|
|
"techage:tubeS", "techage:tubeA",
|
2020-04-15 23:21:22 +03:00
|
|
|
"techage:ta4_tubeS", "techage:ta4_tubeA",
|
|
|
|
"techage:tube_wall_entry",
|
2022-01-03 23:40:31 +03:00
|
|
|
},
|
2019-03-02 14:24:48 +03:00
|
|
|
after_place_tube = function(pos, param2, tube_type, num_tubes, tbl)
|
2020-03-19 00:35:23 +03:00
|
|
|
local name = minetest.get_node(pos).name
|
|
|
|
if name == "techage:tubeS" or name == "techage:tubeA" then
|
|
|
|
minetest.swap_node(pos, {name = "techage:tube"..tube_type, param2 = param2})
|
2020-04-15 23:21:22 +03:00
|
|
|
elseif name == "techage:tube_wall_entry" then
|
|
|
|
minetest.swap_node(pos, {name = "techage:tube_wall_entry", param2 = param2})
|
2020-03-19 00:35:23 +03:00
|
|
|
else
|
|
|
|
minetest.swap_node(pos, {name = "techage:ta4_tube"..tube_type, param2 = param2})
|
|
|
|
end
|
2019-03-02 14:24:48 +03:00
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
techage.Tube = Tube
|
|
|
|
|
|
|
|
minetest.register_node("techage:tubeS", {
|
2021-05-13 18:52:07 +03:00
|
|
|
description = S("TechAge Tube"),
|
2019-03-02 14:24:48 +03:00
|
|
|
tiles = { -- Top, base, right, left, front, back
|
2019-03-09 21:26:15 +03:00
|
|
|
"techage_tube_tube.png^[transformR90",
|
|
|
|
"techage_tube_tube.png^[transformR90",
|
|
|
|
"techage_tube_tube.png",
|
|
|
|
"techage_tube_tube.png",
|
|
|
|
"techage_tube_hole.png",
|
|
|
|
"techage_tube_hole.png",
|
2019-03-02 14:24:48 +03:00
|
|
|
},
|
2022-01-03 23:40:31 +03:00
|
|
|
|
2019-03-02 14:24:48 +03:00
|
|
|
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
|
|
|
if not Tube:after_place_tube(pos, placer, pointed_thing) then
|
|
|
|
minetest.remove_node(pos)
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end,
|
2022-01-03 23:40:31 +03:00
|
|
|
|
2019-03-02 14:24:48 +03:00
|
|
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
|
|
|
Tube:after_dig_tube(pos, oldnode, oldmetadata)
|
|
|
|
end,
|
2022-01-03 23:40:31 +03:00
|
|
|
|
2019-03-02 14:24:48 +03:00
|
|
|
paramtype2 = "facedir",
|
|
|
|
drawtype = "nodebox",
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-2/8, -2/8, -4/8, 2/8, 2/8, 4/8},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = { -1/4, -1/4, -1/2, 1/4, 1/4, 1/2 },
|
|
|
|
},
|
|
|
|
collision_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = { -1/4, -1/4, -1/2, 1/4, 1/4, 1/2 },
|
|
|
|
},
|
|
|
|
on_rotate = screwdriver.disallow,
|
|
|
|
paramtype = "light",
|
2021-03-19 22:06:22 +03:00
|
|
|
use_texture_alpha = techage.CLIP,
|
2019-03-02 14:24:48 +03:00
|
|
|
sunlight_propagates = true,
|
|
|
|
is_ground_content = false,
|
2020-09-04 14:57:16 +03:00
|
|
|
groups = {choppy=2, cracky=3},
|
2019-03-02 14:24:48 +03:00
|
|
|
sounds = default.node_sound_wood_defaults(),
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node("techage:tubeA", {
|
2021-05-13 18:52:07 +03:00
|
|
|
description = S("TechAge Tube"),
|
2019-03-02 14:24:48 +03:00
|
|
|
tiles = { -- Top, base, right, left, front, back
|
2019-03-09 21:26:15 +03:00
|
|
|
"techage_tube_knee2.png",
|
|
|
|
"techage_tube_hole2.png^[transformR180",
|
|
|
|
"techage_tube_knee.png^[transformR270",
|
|
|
|
"techage_tube_knee.png",
|
|
|
|
"techage_tube_knee2.png",
|
|
|
|
"techage_tube_hole2.png",
|
2019-03-02 14:24:48 +03:00
|
|
|
},
|
2022-01-03 23:40:31 +03:00
|
|
|
|
2019-03-02 14:24:48 +03:00
|
|
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
|
|
|
Tube:after_dig_tube(pos, oldnode, oldmetadata)
|
|
|
|
end,
|
2022-01-03 23:40:31 +03:00
|
|
|
|
2019-03-02 14:24:48 +03:00
|
|
|
paramtype2 = "facedir",
|
|
|
|
drawtype = "nodebox",
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-2/8, -4/8, -2/8, 2/8, 2/8, 2/8},
|
|
|
|
{-2/8, -2/8, -4/8, 2/8, 2/8, -2/8},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = { -1/4, -1/2, -1/2, 1/4, 1/4, 1/4 },
|
|
|
|
},
|
|
|
|
collision_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = { -1/4, -1/2, -1/2, 1/4, 1/4, 1/4 },
|
|
|
|
},
|
|
|
|
on_rotate = screwdriver.disallow,
|
|
|
|
paramtype = "light",
|
2021-03-19 22:06:22 +03:00
|
|
|
use_texture_alpha = techage.CLIP,
|
2019-03-02 14:24:48 +03:00
|
|
|
sunlight_propagates = true,
|
|
|
|
is_ground_content = false,
|
2020-09-04 14:57:16 +03:00
|
|
|
groups = {choppy=2, cracky=3, not_in_creative_inventory=1},
|
2019-03-02 14:24:48 +03:00
|
|
|
sounds = default.node_sound_wood_defaults(),
|
|
|
|
drop = "techage:tubeS",
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "techage:tubeS 4",
|
|
|
|
recipe = {
|
|
|
|
{"default:steel_ingot", "", "group:wood"},
|
|
|
|
{"", "group:wood", ""},
|
|
|
|
{"group:wood", "", "default:tin_ingot"},
|
|
|
|
},
|
2022-01-04 21:40:27 +03:00
|
|
|
})
|