2014-08-12 21:08:11 +02:00
|
|
|
-----------------------------------------------------------------------------------------------
|
|
|
|
-- Ferns - Tree Fern 0.1.1
|
|
|
|
-----------------------------------------------------------------------------------------------
|
|
|
|
-- by Mossmanikin
|
2018-02-18 01:28:43 +01:00
|
|
|
-- Contains code from: biome_lib
|
2017-08-03 15:02:56 +02:00
|
|
|
-- Looked at code from: default , trees
|
2014-08-12 21:08:11 +02:00
|
|
|
-----------------------------------------------------------------------------------------------
|
|
|
|
|
2017-08-03 15:02:56 +02:00
|
|
|
-- support for i18n
|
2020-02-15 15:32:06 +01:00
|
|
|
local S = minetest.get_translator("ferns")
|
2017-08-03 15:02:56 +02:00
|
|
|
|
2014-08-22 09:07:27 +02:00
|
|
|
assert(abstract_ferns.config.enable_treefern == true)
|
|
|
|
|
2014-08-12 21:08:11 +02:00
|
|
|
abstract_ferns.grow_tree_fern = function(pos)
|
2014-08-22 10:15:03 +02:00
|
|
|
|
2019-04-12 00:10:44 +02:00
|
|
|
local pos_aux = {x = pos.x, y = pos.y + 1, z = pos.z}
|
|
|
|
local name = minetest.get_node(pos_aux).name
|
|
|
|
if name ~= "air" and name ~= "ferns:sapling_tree_fern"
|
|
|
|
and name ~= "default:junglegrass" then
|
2014-08-22 10:15:03 +02:00
|
|
|
return
|
|
|
|
end
|
2017-08-03 15:02:56 +02:00
|
|
|
|
2015-06-21 10:39:41 +02:00
|
|
|
local size = math.random(1, 4) + math.random(1, 4)
|
|
|
|
if (size > 5) then
|
|
|
|
size = 10 - size
|
|
|
|
end
|
2015-06-21 13:37:03 +02:00
|
|
|
size = size + 1
|
2014-08-22 10:15:03 +02:00
|
|
|
local crown = ({ "ferns:tree_fern_leaves", "ferns:tree_fern_leaves_02" })[math.random(1, 2)]
|
2017-08-03 15:02:56 +02:00
|
|
|
|
2014-08-23 13:14:03 +02:00
|
|
|
local i = 1
|
2017-03-15 02:23:33 +01:00
|
|
|
local brk = false
|
|
|
|
while (i < size) do
|
2019-04-12 00:10:44 +02:00
|
|
|
pos_aux.y = pos.y + i
|
|
|
|
name = minetest.get_node(pos_aux).name
|
|
|
|
if not (name == "air" or (i == 1 and name == "ferns:sapling_tree_fern")) then
|
2017-03-15 02:23:33 +01:00
|
|
|
brk = true
|
2014-08-23 13:14:03 +02:00
|
|
|
break
|
|
|
|
end
|
2018-10-25 16:27:54 +02:00
|
|
|
minetest.swap_node({x = pos.x, y = pos.y + i, z = pos.z}, { name = "ferns:fern_trunk" })
|
2014-08-23 13:14:03 +02:00
|
|
|
i = i + 1
|
2014-08-12 21:08:11 +02:00
|
|
|
end
|
2017-03-15 02:23:33 +01:00
|
|
|
if not brk then
|
2018-10-25 16:27:54 +02:00
|
|
|
minetest.swap_node({x = pos.x, y = pos.y + i - 1, z = pos.z}, { name = crown })
|
2017-03-15 02:23:33 +01:00
|
|
|
end
|
2014-08-12 21:08:11 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------------------------
|
|
|
|
-- TREE FERN LEAVES
|
|
|
|
-----------------------------------------------------------------------------------------------
|
2014-08-23 13:14:03 +02:00
|
|
|
|
|
|
|
-- TODO: Both of these nodes look the same?
|
|
|
|
|
2014-08-12 21:08:11 +02:00
|
|
|
minetest.register_node("ferns:tree_fern_leaves", {
|
2017-08-03 15:02:56 +02:00
|
|
|
description = S("Tree Fern Crown (Dicksonia)"),
|
2014-08-12 21:08:11 +02:00
|
|
|
drawtype = "plantlike",
|
2017-06-16 20:16:18 +02:00
|
|
|
visual_scale = math.sqrt(8),
|
2014-08-12 21:08:11 +02:00
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
|
|
|
--tiles = {"[combine:32x32:0,0=top_left.png:0,16=bottom_left.png:16,0=top_right.png:16,16=bottom_right.png"},
|
|
|
|
tiles = {"ferns_fern_tree.png"},
|
|
|
|
inventory_image = "ferns_fern_tree_inv.png",
|
|
|
|
walkable = false,
|
|
|
|
groups = {snappy=3,flammable=2,attached_node=1},
|
|
|
|
drop = {
|
2015-06-21 10:39:41 +02:00
|
|
|
max_items = 2,
|
2014-08-12 21:08:11 +02:00
|
|
|
items = {
|
2015-06-21 10:39:41 +02:00
|
|
|
{
|
|
|
|
-- occasionally, drop a second sapling instead of leaves
|
|
|
|
-- (extra saplings can also be obtained by replanting and
|
|
|
|
-- reharvesting leaves)
|
|
|
|
items = {"ferns:sapling_tree_fern"},
|
|
|
|
rarity = 10,
|
|
|
|
},
|
2014-08-12 21:08:11 +02:00
|
|
|
{
|
|
|
|
items = {"ferns:sapling_tree_fern"},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
items = {"ferns:tree_fern_leaves"},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-7/16, -1/2, -7/16, 7/16, 0, 7/16},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
minetest.register_node("ferns:tree_fern_leaves_02", {
|
|
|
|
drawtype = "plantlike",
|
2017-06-16 20:16:18 +02:00
|
|
|
visual_scale = math.sqrt(8),
|
2014-08-12 21:08:11 +02:00
|
|
|
paramtype = "light",
|
|
|
|
tiles = {"ferns_fern_big.png"},
|
|
|
|
walkable = false,
|
|
|
|
groups = {snappy=3,flammable=2,attached_node=1,not_in_creative_inventory=1},
|
|
|
|
drop = {
|
2015-06-21 10:39:41 +02:00
|
|
|
max_items = 2,
|
2014-08-12 21:08:11 +02:00
|
|
|
items = {
|
2015-06-21 10:39:41 +02:00
|
|
|
{
|
|
|
|
-- occasionally, drop a second sapling instead of leaves
|
|
|
|
-- (extra saplings can also be obtained by replanting and
|
|
|
|
-- reharvesting leaves)
|
|
|
|
items = {"ferns:sapling_tree_fern"},
|
|
|
|
rarity = 10,
|
|
|
|
},
|
2014-08-12 21:08:11 +02:00
|
|
|
{
|
|
|
|
items = {"ferns:sapling_tree_fern"},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
items = {"ferns:tree_fern_leaves"},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-7/16, -1/2, -7/16, 7/16, 0, 7/16},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
-----------------------------------------------------------------------------------------------
|
|
|
|
-- FERN TRUNK
|
|
|
|
-----------------------------------------------------------------------------------------------
|
|
|
|
minetest.register_node("ferns:fern_trunk", {
|
2017-08-03 15:02:56 +02:00
|
|
|
description = S("Fern Trunk (Dicksonia)"),
|
2014-08-12 21:08:11 +02:00
|
|
|
drawtype = "nodebox",
|
|
|
|
paramtype = "light",
|
|
|
|
tiles = {
|
|
|
|
"ferns_fern_trunk_top.png",
|
|
|
|
"ferns_fern_trunk_top.png",
|
|
|
|
"ferns_fern_trunk.png"
|
|
|
|
},
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-1/8, -1/2, -1/8, 1/8, 1/2, 1/8},
|
|
|
|
},
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
|
|
|
|
},
|
|
|
|
groups = {tree=1,choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1},
|
|
|
|
sounds = default.node_sound_wood_defaults(),
|
|
|
|
after_destruct = function(pos,oldnode)
|
|
|
|
local node = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
|
2017-08-03 15:02:56 +02:00
|
|
|
if node.name == "ferns:fern_trunk" then
|
|
|
|
minetest.dig_node({x=pos.x,y=pos.y+1,z=pos.z})
|
2014-08-12 21:08:11 +02:00
|
|
|
minetest.add_item(pos,"ferns:fern_trunk")
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------------------------
|
|
|
|
-- TREE FERN SAPLING
|
|
|
|
-----------------------------------------------------------------------------------------------
|
|
|
|
minetest.register_node("ferns:sapling_tree_fern", {
|
2017-08-03 15:02:56 +02:00
|
|
|
description = S("Tree Fern Sapling (Dicksonia)"),
|
2014-08-12 21:08:11 +02:00
|
|
|
drawtype = "plantlike",
|
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
|
|
|
tiles = {"ferns_sapling_tree_fern.png"},
|
|
|
|
inventory_image = "ferns_sapling_tree_fern.png",
|
|
|
|
walkable = false,
|
2022-01-11 18:55:22 +01:00
|
|
|
groups = {snappy=3,flammable=2,flora=1,attached_node=1,sapling=1},
|
2014-08-12 21:08:11 +02:00
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-7/16, -1/2, -7/16, 7/16, 0, 7/16},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
-- abm
|
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = "ferns:sapling_tree_fern",
|
|
|
|
interval = 1000,
|
|
|
|
chance = 4,
|
|
|
|
action = function(pos, node, _, _)
|
|
|
|
abstract_ferns.grow_tree_fern({x = pos.x, y = pos.y-1, z = pos.z})
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------------------------
|
|
|
|
-- GENERATE TREE FERN
|
|
|
|
-----------------------------------------------------------------------------------------------
|
2014-08-20 10:35:08 +02:00
|
|
|
|
2014-08-12 21:08:11 +02:00
|
|
|
-- in jungles
|
2014-08-22 09:04:34 +02:00
|
|
|
if abstract_ferns.config.enable_treeferns_in_jungle == true then
|
2021-07-19 20:18:01 +02:00
|
|
|
biome_lib.register_on_generate({
|
2014-08-20 10:35:08 +02:00
|
|
|
surface = {
|
|
|
|
"default:dirt_with_grass",
|
2018-03-17 21:37:02 +01:00
|
|
|
"default:dirt_with_rainforest_litter", -- minetest >= 0.4.16
|
2014-08-20 10:35:08 +02:00
|
|
|
"default:sand",
|
2014-08-20 12:37:48 +02:00
|
|
|
"default:desert_sand",
|
2014-08-20 10:35:08 +02:00
|
|
|
},
|
|
|
|
max_count = 35,--27,
|
|
|
|
avoid_nodes = {"default:tree"},
|
|
|
|
avoid_radius = 4,
|
|
|
|
rarity = 50,
|
|
|
|
seed_diff = 329,
|
|
|
|
min_elevation = -10,
|
|
|
|
near_nodes = {"default:jungletree"},
|
|
|
|
near_nodes_size = 6,
|
|
|
|
near_nodes_vertical = 2,--4,
|
|
|
|
near_nodes_count = 1,
|
|
|
|
plantlife_limit = -0.9,
|
|
|
|
humidity_max = -1.0,
|
|
|
|
humidity_min = 0.4,
|
|
|
|
temp_max = -0.5,
|
|
|
|
temp_min = 0.13,
|
2014-08-12 21:08:11 +02:00
|
|
|
},
|
2014-08-20 10:35:08 +02:00
|
|
|
abstract_ferns.grow_tree_fern
|
|
|
|
)
|
2014-08-12 21:08:11 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
-- for oases & tropical beaches
|
2014-08-22 09:04:34 +02:00
|
|
|
if abstract_ferns.config.enable_treeferns_in_oases == true then
|
2021-07-19 20:18:01 +02:00
|
|
|
biome_lib.register_on_generate({
|
2014-08-20 10:35:08 +02:00
|
|
|
surface = {
|
|
|
|
"default:sand"--,
|
|
|
|
--"default:desert_sand"
|
|
|
|
},
|
|
|
|
max_count = 35,
|
|
|
|
rarity = 50,
|
|
|
|
seed_diff = 329,
|
|
|
|
neighbors = {"default:desert_sand"},
|
|
|
|
ncount = 1,
|
|
|
|
min_elevation = 1,
|
2018-03-17 21:37:02 +01:00
|
|
|
near_nodes = {"default:water_source","default:river_water_source"},
|
2014-08-20 10:35:08 +02:00
|
|
|
near_nodes_size = 2,
|
|
|
|
near_nodes_vertical = 1,
|
|
|
|
near_nodes_count = 1,
|
|
|
|
plantlife_limit = -0.9,
|
|
|
|
humidity_max = -1.0,
|
|
|
|
humidity_min = 1.0,
|
|
|
|
temp_max = -1.0,
|
|
|
|
temp_min = 1.0,
|
2014-08-12 21:08:11 +02:00
|
|
|
},
|
2014-08-20 10:35:08 +02:00
|
|
|
abstract_ferns.grow_tree_fern
|
2014-08-12 21:08:11 +02:00
|
|
|
)
|
|
|
|
end
|