Add banana tree, wood and bananas. Yum!

This commit is contained in:
vlapsley 2015-09-18 21:54:11 +10:00
parent 59b6ec445c
commit ddeaef6a06
9 changed files with 142 additions and 0 deletions

View File

@ -166,6 +166,9 @@ function vmg.generate(minp, maxp, seed)
local c_tree = minetest.get_content_id("default:tree")
local c_leaves = minetest.get_content_id("default:leaves")
local c_apple = minetest.get_content_id("default:apple")
local c_banana_tree = minetest.get_content_id("valleys_mapgen:banana_tree")
local c_banana_leaves = minetest.get_content_id("valleys_mapgen:banana_leaves")
local c_banana = minetest.get_content_id("valleys_mapgen:banana")
local c_jungletree = minetest.get_content_id("default:jungletree")
local c_jungleleaves = minetest.get_content_id("default:jungleleaves")
local c_pinetree = minetest.get_content_id("default:pinetree")
@ -404,6 +407,13 @@ function vmg.generate(minp, maxp, seed)
local height = math.floor(8 + 4 * rand)
local radius = 5 + 3 * rand
vmg.make_jungle_tree(pos, data, a, height, radius, c_jungletree, c_jungleleaves, c_air, c_ignore)
elseif v15 > -0.6 and temp >= 1.8 and humidity > 2.2 and v16 > 1.8 then -- banana tree
local rand = math.random()
local height = math.floor(4 + 2.5 * rand)
local radius = 3 + rand
if math.random(100) <= 10 then
vmg.make_banana_tree(pos, data, a, height, radius, c_banana_tree, c_banana_leaves, c_banana, c_air, c_ignore)
end
elseif temp > 0.38 and temp < 1 and humidity > 0.9 and v15 > 0 and v15 < 0.55 then -- Fir Tree
local rand = math.random()
local height = math.floor(9 + 6 * rand)

View File

@ -193,6 +193,102 @@ minetest.register_craft({
}
})
minetest.register_node("valleys_mapgen:banana_tree", {
description = "Banana Tree",
tiles = {"vmg_banana_tree_top.png", "vmg_banana_tree_top.png", "vmg_banana_tree.png"},
paramtype2 = "facedir",
is_ground_content = false,
groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
sounds = default.node_sound_wood_defaults(),
on_place = minetest.rotate_node
})
minetest.register_node("valleys_mapgen:banana_sapling", {
description = "Banana Sapling",
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"vmg_banana_sapling.png"},
inventory_image = "vmg_banana_sapling.png",
wield_image = "vmg_banana_sapling.png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
},
groups = {snappy=2,dig_immediate=3,flammable=2,attached_node=1,sapling=1},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("valleys_mapgen:banana_leaves", {
description = "Banana Leaves",
drawtype = "allfaces_optional",
waving = 1,
visual_scale = 1.3,
tiles = {"vmg_banana_leaves.png"},
paramtype = "light",
is_ground_content = false,
groups = {snappy=3, leafdecay=7, flammable=2, leaves=1},
drop = {
max_items = 1,
items = {
{
-- player will get sapling with 1/20 chance
items = {'valleys_mapgen:banana_sapling'},
rarity = 20,
},
{
-- player will get leaves only if he get no saplings,
-- this is because max_items is 1
items = {'valleys_mapgen:banana_leaves'},
}
}
},
sounds = default.node_sound_leaves_defaults(),
after_place_node = default.after_place_leaves,
})
minetest.register_node("valleys_mapgen:banana_wood", {
description = "Banana Wood Planks",
tiles = {"vmg_banana_wood.png"},
is_ground_content = false,
groups = {choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_craft({
output = "valleys_mapgen:banana_wood 5",
recipe = {
{"valleys_mapgen:banana_tree"}
}
})
minetest.register_node("valleys_mapgen:banana", {
description = "Banana",
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"vmg_banana.png"},
inventory_image = "vmg_banana.png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
is_ground_content = false,
selection_box = {
type = "fixed",
fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2}
},
groups = {fleshy=3,dig_immediate=3,flammable=2,leafdecay=3,leafdecay_drop=1},
on_use = minetest.item_eat(3),
sounds = default.node_sound_leaves_defaults(),
after_place_node = function(pos, placer, itemstack)
if placer:is_player() then
minetest.set_node(pos, {name="valleys_mapgen:banana", param2=1})
end
end,
})
----------------------
-- Flowers / Plants --
----------------------

BIN
textures/vmg_banana.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 826 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 B

View File

@ -52,6 +52,27 @@ function default.grow_tree(pos, is_apple_tree) -- Override default function to g
vm:update_map()
end
function default.grow_banana_tree(pos)
-- individual parameters
local rand = math.random()
local height = math.floor(4 + 2.5 * rand)
local radius = 3 + rand
-- VoxelManip stuff
local leaves = minetest.get_content_id("valleys_mapgen:banana_leaves")
local trunk = minetest.get_content_id("valleys_mapgen:banana_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 - 4, y = pos.y, z = pos.z - 4}, {x = pos.x + 4, y = pos.y + height + 4, z = pos.z + 4})
local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
local data = vm:get_data()
vmg.make_banana_tree(pos, data, area, height, radius, trunk, leaves, minetest.get_content_id("valleys_mapgen:banana"), air, ignore)
vm:set_data(data)
vm:write_to_map()
vm:update_map()
end
function default.grow_jungle_tree(pos)
local rand = math.random()
local height = math.floor(8 + 4 * rand)
@ -140,6 +161,21 @@ function vmg.make_apple_tree(pos, data, area, height, radius, trunk, leaves, fru
vmg.make_leavesblob(pos, data, area, leaves, air, ignore, {x = radius, y = radius, z = radius}, np, 0.06, fruit)
end
function vmg.make_banana_tree(pos, data, area, height, radius, trunk, leaves, fruit, air, ignore)
if vmg.loglevel >= 3 then
print("[Valleys Mapgen] Generating banana 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
local np = {offset = 0.8, scale = 0.4, spread = {x = 8, y = 4, z = 8}, octaves = 3, persist = 0.5}
pos.y = pos.y + height - 1
vmg.make_leavesblob(pos, data, area, leaves, air, ignore, {x = radius, y = radius, z = radius}, np, 0.06, fruit)
end
local function make_jungle_root(x0, y0, z0, data, area, tree, air)
local ystride = area.ystride
local ybot = y0 - 1