Add mangrove tree and fern.

master
vlapsley 2015-10-30 21:41:37 +11:00 committed by Gael-de-Sailly
parent 3e13d4966b
commit 9be8720c34
11 changed files with 127 additions and 1 deletions

View File

@ -127,6 +127,7 @@ register_dirts("Sandy")
-- Banana tree: textures by demon_boy
-- Birch tree: textures from Forest mod by Gael-de-Sailly
-- Cherry Blossom tree: textures by demon_boy
-- Mangrove tree: textures by demon_boy
-- Fir tree: Fir trees don't exist in the default game. Textures from Forest mod by Gael-de-Sailly
-- Willow tree: textures from Forest mod by Gael-de-Sailly
@ -164,6 +165,13 @@ vmg.treelist = {
leaf_tile="fir_leaves",
drop_rarity=20,
trunk_dia=1.0},
{name="mangrove",
desc="Mangrove",
leaf="leaves",
leaf_desc="Leaves",
leaf_tile="mangrove_leaves",
drop_rarity=20,
trunk_dia=0.5},
{name="willow",
desc="Willow",
leaf="leaves",
@ -323,6 +331,7 @@ end
-- Calla Lily: texture by demon_boy
-- Gerbera: texture by demon_boy
-- Hibiscus: texture by demon_boy
-- Mangrove Fern: texture by demon_boy
-- Orchid: texture by demon_boy
vmg.plantlist = {
@ -332,6 +341,7 @@ vmg.plantlist = {
{"calla_lily", "Calla Lily", 1, "true", "flowerwhitedye", {-0.5, -0.5, -0.5, 0.5, -0.3125, 0.5}},
{"gerbera", "Gerbera", 0, "true", "flowerpinkdye", {-0.15, -0.5, -0.15, 0.15, 0.2, 0.15}},
{"hibiscus", "Hibiscus", 1, "false", "flowerwhitedye", {-0.5, -0.5, -0.5, 0.5, -0.3125, 0.5}},
{"mangrove_fern", "Mangrove Fern", 1, "false", "flowernodye", {-0.5, -0.5, -0.5, 0.5, -0.3125, 0.5}},
{"orchid", "Orchid", 1, "true", "flowerwhitedye", {-0.5, -0.5, -0.5, 0.5, -0.3125, 0.5}},
}
@ -374,6 +384,16 @@ for i in ipairs(vmg.plantlist) do
end
minetest.register_node("valleys_mapgen:mangrove_roots", {
description = "Mangrove Roots",
drawtype = "plantlike",
tiles = {"vmg_mangrove_roots.png"},
paramtype = "light",
is_ground_content = true,
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("valleys_mapgen:huge_mushroom_cap", {
description = "Huge Mushroom Cap",
tiles = {"vmg_mushroom_giant_cap.png", "vmg_mushroom_giant_under.png", "vmg_mushroom_giant_cap.png"},

View File

@ -69,6 +69,16 @@ if vmg.define("plants", true) then
end,
})
vmg.register_plant({
nodes = {"valleys_mapgen:mangrove_fern"},
cover = 0.1,
density = 0.05,
priority = 50,
check = function(t, pos)
return t.v2 < 0.03 and t.temp >= 1.7 and t.humidity > 1.5 and pos.y < 6
end,
})
vmg.register_plant({
nodes = {"valleys_mapgen:orchid"},
cover = 0.02,
@ -217,6 +227,28 @@ if vmg.define("trees", true) then
end,
})
vmg.register_plant({ -- Mangrove tree
nodes = {
trunk = "valleys_mapgen:mangrove_tree",
leaves = "valleys_mapgen:mangrove_leaves",
roots = "valleys_mapgen:mangrove_roots",
air = "air", ignore = "ignore",
},
cover = 0.3,
density = 0.2,
priority = 72,
check = function(t, pos)
return t.v2 < 0.03 and t.temp >= 1.7 and t.humidity > 1.5 and pos.y < 5
end,
grow = function(nodes, pos, data, area)
local rand = math.random()
local height = math.floor(3 + 1.5 * rand)
local radius = 2 + 1.5 * rand
vmg.make_mangrove_tree(pos, data, area, height, radius, nodes.trunk, nodes.leaves, nodes.roots, nodes.air, nodes.ignore)
end,
})
local leaves_colors = vmg.define("leaves_colors", true)
vmg.register_plant({ -- Apple tree
@ -236,7 +268,7 @@ if vmg.define("trees", true) then
density = 0.05,
priority = 66,
check = function(t, pos)
return t.v15 < 0.6 and t.temp >= 0.85 and t.temp < 2.3 and t.humidity < 3 and t.v16 < 2 and t.v14 > -0.5 and t.v13 < 0.8
return t.v15 < 0.6 and t.temp >= 0.85 and t.temp < 2.3 and t.humidity < 3 and t.v16 < 2 and t.v14 > -0.5 and t.v13 < 0.8 and pos.y > 2
end,
grow = function(nodes, pos, data, area)
local rand = math.random()

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 958 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 669 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 737 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

View File

@ -75,6 +75,22 @@ minetest.register_abm({
end
})
-- Mangrove sapling growth
minetest.register_abm({
nodenames = {"valleys_mapgen:mangrove_sapling"},
interval = 20,
chance = 50,
action = function(pos, node)
if not can_grow(pos) then
return
end
minetest.log("action", "A mangrove sapling grows into a tree at "..
minetest.pos_to_string(pos))
vmg.grow_mangrove_tree(pos)
end
})
-- Willow sapling growth
minetest.register_abm({
nodenames = {"valleys_mapgen:willow_sapling"},
@ -204,6 +220,26 @@ function default.grow_jungle_tree(pos)
vm:update_map()
end
function default.grow_mangrove_tree(pos)
local rand = math.random()
local height = math.floor(3 + 2 * rand)
local radius = 3 + 2 * rand
local leaves = minetest.get_content_id("default:mangrove_leaves")
local trunk = minetest.get_content_id("default:mangrove_tree")
local air = minetest.get_content_id("air")
local ignore = minetest.get_content_id("ignore")
local vm = minetest.get_voxel_manip()
local emin, emax = vm:read_from_map({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2}, {x = pos.x + 3, y = pos.y + height + 2, z = pos.z + 3})
local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
local data = vm:get_data()
vmg.make_mangrove_tree(pos, data, area, height, radius, trunk, leaves, air, ignore)
vmg.execute_after_mapgen()
vm:set_data(data)
vm:write_to_map()
vm:update_map()
end
function default.grow_pine_tree(pos)
local rand = math.random()
local height = math.floor(9 + 6 * rand)
@ -360,6 +396,28 @@ local function make_jungle_root(x0, y0, z0, data, area, tree, air)
end
end
local function make_mangrove_root(x0, y0, z0, data, area, roots, air)
local ystride = area.ystride
local ybot = y0 - 1
for x = x0 - 1, x0 + 1 do
for z = z0 - 1, z0 + 1 do -- iterate in a 3x3 square around the trunk
local iv = area:index(x, ybot, z)
for i = 0, 5 do
if data[iv] == air then -- find the ground level
if math.random() < 0.6 then
data[iv-ystride] = roots -- make mangrove root below
if math.random() < 0.6 then
data[iv] = roots -- make mangrove root at this air node
end
end
break
end
iv = iv + ystride -- increment by one node up
end
end
end
end
function vmg.make_jungle_tree(pos, data, area, height, radius, trunk, leaves, air, ignore)
if vmg.loglevel >= 3 then
print("[Valleys Mapgen] Generating jungle tree at " .. minetest.pos_to_string(pos) .. " ...")
@ -376,6 +434,22 @@ function vmg.make_jungle_tree(pos, data, area, height, radius, trunk, leaves, ai
vmg.make_leavesblob(pos, data, area, leaves, air, ignore, {x = radius, y = radius * 0.5, z = radius}, np)
end
function vmg.make_mangrove_tree(pos, data, area, height, radius, trunk, leaves, roots, air, ignore)
if vmg.loglevel >= 3 then
print("[Valleys Mapgen] Generating mangrove tree at " .. minetest.pos_to_string(pos) .. " ...")
end
local ystride = area.ystride -- Useful to get the index above
local iv = area:indexp(pos)
for i = 1, height do -- Build the trunk
data[iv] = trunk
iv = iv + ystride -- increment by one node up
end
vmg.register_after_mapgen(make_mangrove_root, pos.x, pos.y, pos.z, data, area, roots, air)
local np = {offset = 0.8, scale = 0.4, spread = {x = 8, y = 4, z = 8}, octaves = 3, persist = 0.8}
pos.y = pos.y + height
vmg.make_leavesblob(pos, data, area, leaves, air, ignore, {x = radius, y = radius * 0.5, z = radius}, np)
end
function vmg.make_fir_tree(pos, data, area, height, radius, trunk, leaves, air, ignore)
if vmg.loglevel >= 3 then
print("[Valleys Mapgen] Generating fir tree at " .. minetest.pos_to_string(pos) .. " ...")