2017-08-03 15:02:56 +02:00
|
|
|
-- support for i18n
|
2020-02-15 15:32:06 +01:00
|
|
|
local S = minetest.get_translator("youngtrees")
|
2017-08-03 15:02:56 +02:00
|
|
|
|
2020-07-24 00:08:50 +02:00
|
|
|
local random = math.random
|
|
|
|
|
2017-08-03 15:02:56 +02:00
|
|
|
abstract_youngtrees = {}
|
2014-08-12 21:08:11 +02:00
|
|
|
|
2021-12-24 09:31:30 +01:00
|
|
|
local youngtrees_youngtrees_rarity = tonumber(minetest.settings:get("youngtrees_youngtrees_rarity")) or 100
|
|
|
|
local youngtrees_youngtrees_rarity_fertility = tonumber(minetest.settings:get("youngtrees_youngtrees_rarity_fertility")) or 0.5
|
|
|
|
local youngtrees_youngtrees_fertility = tonumber(minetest.settings:get("youngtrees_youngtrees_fertility")) or -0.3
|
|
|
|
|
|
|
|
|
2014-08-12 21:08:11 +02:00
|
|
|
minetest.register_node("youngtrees:bamboo", {
|
2017-08-03 15:02:56 +02:00
|
|
|
description = S("Young Bamboo Tree"),
|
2014-08-19 01:16:09 +02:00
|
|
|
drawtype="nodebox",
|
|
|
|
tiles = {"bamboo.png"},
|
|
|
|
paramtype = "light",
|
2014-08-12 21:08:11 +02:00
|
|
|
walkable = false,
|
|
|
|
is_ground_content = true,
|
2014-08-19 01:16:09 +02:00
|
|
|
node_box = {
|
2014-08-12 21:08:11 +02:00
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
2014-08-19 01:16:09 +02:00
|
|
|
{-0.058251,-0.500000,-0.413681,0.066749,0.500000,-0.282500}, --NodeBox 1
|
|
|
|
{-0.058251,-0.500000,-0.103123,0.066749,0.500000,0.038672}, --NodeBox 2
|
|
|
|
{-0.058251,-0.500000,0.181227,0.066749,0.500000,0.342500}, --NodeBox 3
|
|
|
|
}
|
|
|
|
},
|
2014-08-12 21:08:11 +02:00
|
|
|
groups = {snappy=3,flammable=2},
|
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
2014-06-04 22:09:06 +02:00
|
|
|
drop = 'trunks:twig_1'
|
2014-08-12 21:08:11 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node("youngtrees:youngtree2_middle",{
|
2017-08-03 15:02:56 +02:00
|
|
|
description = S("Young Tree 2 (middle)"),
|
2014-08-12 21:08:11 +02:00
|
|
|
drawtype="nodebox",
|
2014-08-19 01:16:09 +02:00
|
|
|
tiles = {"youngtree2branch.png"},
|
|
|
|
inventory_image = "youngtree2branch.png",
|
2017-08-03 15:02:56 +02:00
|
|
|
wield_image = "youngtree2branch.png",
|
2014-08-12 21:08:11 +02:00
|
|
|
paramtype = "light",
|
2014-08-19 01:16:09 +02:00
|
|
|
walkable = false,
|
2014-08-12 21:08:11 +02:00
|
|
|
is_ground_content = true,
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{0.125000,-0.500000,-0.500000,0.500000,-0.187500,-0.125000}, --NodeBox 1
|
|
|
|
{-0.187500,-0.187500,-0.500000,0.500000,0.125000,0.250000}, --NodeBox 2
|
|
|
|
{-0.500000,0.125000,-0.500000,0.500000,0.500000,0.500000}, --NodeBox 3
|
|
|
|
}
|
|
|
|
},
|
2021-12-24 09:31:30 +01:00
|
|
|
groups = {snappy=3,flammable=2,attached_node=1},
|
2014-08-12 21:08:11 +02:00
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
2014-06-04 22:09:06 +02:00
|
|
|
drop = 'trunks:twig_1'
|
2014-08-12 21:08:11 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node("youngtrees:youngtree_top", {
|
2017-08-03 15:02:56 +02:00
|
|
|
description = S("Young Tree (top)"),
|
2014-08-12 21:08:11 +02:00
|
|
|
drawtype = "plantlike",
|
|
|
|
tiles = {"youngtree16xa.png"},
|
|
|
|
inventory_image = "youngtree16xa.png",
|
|
|
|
wield_image = "youngtree16xa.png",
|
|
|
|
paramtype = "light",
|
|
|
|
walkable = false,
|
|
|
|
is_ground_content = true,
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
|
|
|
|
},
|
2021-06-20 02:34:22 +02:00
|
|
|
groups = {snappy=3,flammable=2,attached_node=1},
|
2014-08-12 21:08:11 +02:00
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
2014-06-04 22:09:06 +02:00
|
|
|
drop = 'trunks:twig_1'
|
2014-08-12 21:08:11 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node("youngtrees:youngtree_middle", {
|
2017-08-03 15:02:56 +02:00
|
|
|
description = S("Young Tree (middle)"),
|
2014-08-12 21:08:11 +02:00
|
|
|
drawtype = "plantlike",
|
|
|
|
tiles = {"youngtree16xb.png"},
|
|
|
|
inventory_image = "youngtree16xb.png",
|
|
|
|
wield_image = "youngtree16xb.png",
|
|
|
|
paramtype = "light",
|
|
|
|
walkable = false,
|
|
|
|
is_ground_content = true,
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
|
|
|
|
},
|
2021-06-20 02:34:22 +02:00
|
|
|
groups = {snappy=3,flammable=2,attached_node=1},
|
2014-08-12 21:08:11 +02:00
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
2014-06-04 22:09:06 +02:00
|
|
|
drop = 'trunks:twig_1'
|
2014-08-12 21:08:11 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node("youngtrees:youngtree_bottom", {
|
2017-08-03 15:02:56 +02:00
|
|
|
description = S("Young Tree (bottom)"),
|
2014-08-12 21:08:11 +02:00
|
|
|
drawtype = "plantlike",
|
|
|
|
tiles = {"youngtree16xc.png"},
|
|
|
|
inventory_image = "youngtree16xc.png",
|
|
|
|
wield_image = "youngtree16xc.png",
|
|
|
|
paramtype = "light",
|
|
|
|
walkable = false,
|
|
|
|
is_ground_content = true,
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
|
|
|
|
},
|
2021-06-20 02:34:22 +02:00
|
|
|
groups = {snappy=3,flammable=2,attached_node=1},
|
2014-08-12 21:08:11 +02:00
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
2014-06-04 22:09:06 +02:00
|
|
|
drop = 'trunks:twig_1'
|
2014-08-12 21:08:11 +02:00
|
|
|
})
|
2017-08-03 15:02:56 +02:00
|
|
|
|
|
|
|
|
2021-12-24 09:31:30 +01:00
|
|
|
abstract_youngtrees.grow_youngtree = function(pos)
|
2020-07-24 00:08:50 +02:00
|
|
|
abstract_youngtrees.grow_youngtree_node(pos, random(1,3))
|
2014-08-12 21:08:11 +02:00
|
|
|
end
|
|
|
|
|
2017-08-03 15:02:56 +02:00
|
|
|
|
2021-12-24 09:31:30 +01:00
|
|
|
abstract_youngtrees.grow_youngtree_node = function(pos, height)
|
2014-08-12 21:08:11 +02:00
|
|
|
local right_here = {x=pos.x, y=pos.y+1, z=pos.z}
|
|
|
|
local above_right_here = {x=pos.x, y=pos.y+2, z=pos.z}
|
2017-08-03 15:02:56 +02:00
|
|
|
|
2021-12-24 09:31:30 +01:00
|
|
|
if minetest.get_node(right_here).name == "air" -- instead of check_air = true,
|
2014-08-12 21:08:11 +02:00
|
|
|
or minetest.get_node(right_here).name == "default:junglegrass" then
|
|
|
|
if height == 1 then
|
2021-12-24 09:31:30 +01:00
|
|
|
minetest.swap_node(right_here, {name="youngtrees:youngtree_top"})
|
2014-08-12 21:08:11 +02:00
|
|
|
end
|
|
|
|
if height == 2 then
|
2021-12-24 09:31:30 +01:00
|
|
|
minetest.swap_node(right_here, {name="youngtrees:youngtree_bottom"})
|
|
|
|
minetest.swap_node(above_right_here, {name="youngtrees:youngtree_top"})
|
2017-08-03 15:02:56 +02:00
|
|
|
end
|
2014-08-12 21:08:11 +02:00
|
|
|
if height == 3 then
|
2021-12-24 09:31:30 +01:00
|
|
|
local two_above_right_here = {x=pos.x, y=pos.y+3, z=pos.z}
|
|
|
|
minetest.swap_node(right_here, {name="youngtrees:youngtree_bottom"})
|
|
|
|
minetest.swap_node(above_right_here, {name="youngtrees:youngtree_middle"})
|
|
|
|
minetest.swap_node(two_above_right_here, {name="youngtrees:youngtree_top"})
|
2017-08-03 15:02:56 +02:00
|
|
|
end
|
2014-08-12 21:08:11 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2021-07-19 20:18:01 +02:00
|
|
|
biome_lib.register_on_generate({
|
2021-12-24 09:31:30 +01:00
|
|
|
surface = {
|
|
|
|
"default:dirt_with_grass",
|
|
|
|
"stoneage:grass_with_silex",
|
|
|
|
"sumpf:peat",
|
|
|
|
"sumpf:sumpf"
|
|
|
|
},
|
|
|
|
rarity = youngtrees_youngtrees_rarity,
|
|
|
|
rarity_fertility = youngtrees_youngtrees_rarity_fertility,
|
|
|
|
plantlife_limit = youngtrees_youngtrees_fertility,
|
|
|
|
min_elevation = 1, -- above sea level
|
2014-08-12 21:08:11 +02:00
|
|
|
},
|
2021-12-24 09:31:30 +01:00
|
|
|
abstract_youngtrees.grow_youngtree
|
2017-08-03 15:02:56 +02:00
|
|
|
)
|
2019-01-05 22:50:35 +01:00
|
|
|
|
|
|
|
minetest.log("action", "[youngtrees] loaded.")
|