1
0
mirror of https://github.com/mt-mods/moretrees.git synced 2024-11-05 09:50:34 +01:00
moretrees/node_defs.lua
Vanessa Ezekowitz 4c198fad78 Multiple changes, see below:
Fix replacement of default trees so that it works correctly.  Beeches
now use default tree nodes, but L-systems models.  This redefines the
default tree, wood, leaves, and saplings so that they use moretrees'
textures "Beech" in their descriptions, but only if replacement of
default trees is enabled.

Added backward-compat aliases for this change.

Moved tree replacement mapgen->air aliases to a more logical spot in the
code.

Also, changed out all leaf decay dig_node() calls for nodeupdate(), since the
former calls the latter anyway, and the latter is what does the job.

Increased the palm leaf decay radius to 12.
2013-04-07 22:09:18 -04:00

310 lines
10 KiB
Lua

moretrees.avoidnodes = {}
moretrees.treelist = {
{"apple_tree", "Apple Tree"},
{"oak", "Oak Tree", "acorn", "Acorn", {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 0.8 },
{"sequoia", "Giant Sequoia"},
{"birch", "Birch Tree"},
{"palm", "Palm Tree", "coconut", "Coconut", {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 1.0 },
{"spruce", "Spruce Tree", "spruce_cone", "Spruce Cone", {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 0.8 },
{"pine", "Pine Tree", "pine_cone", "Pine Cone", {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 0.8 },
{"willow", "Willow Tree"},
{"rubber_tree", "Rubber Tree"},
{"jungletree", "Jungle Tree"},
{"fir", "Douglas Fir", "fir_cone", "Fir Cone", {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 0.8 },
}
for i in ipairs(moretrees.treelist) do
local treename = moretrees.treelist[i][1]
local treedesc = moretrees.treelist[i][2]
local fruit = moretrees.treelist[i][3]
local fruitdesc = moretrees.treelist[i][4]
local selbox = moretrees.treelist[i][5]
local vscale = moretrees.treelist[i][6]
if treename ~= "jungletree" then -- the default game provides jungle tree nodes.
minetest.register_node("moretrees:"..treename.."_trunk", {
description = treedesc.." Trunk",
tiles = {
"moretrees_"..treename.."_trunk_top.png",
"moretrees_"..treename.."_trunk_top.png",
"moretrees_"..treename.."_trunk.png"
},
is_ground_content = true,
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("moretrees:"..treename.."_trunk_sideways", {
description = "Sideways "..treedesc.." Trunk",
tiles = {
"moretrees_"..treename.."_trunk.png^[transformR90",
"moretrees_"..treename.."_trunk.png^[transformR90",
"moretrees_"..treename.."_trunk_top.png",
"moretrees_"..treename.."_trunk_top.png",
"moretrees_"..treename.."_trunk.png^[transformR90",
"moretrees_"..treename.."_trunk.png^[transformR90"
},
is_ground_content = true,
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
sounds = default.node_sound_wood_defaults(),
paramtype2 = "facedir",
})
minetest.register_node("moretrees:"..treename.."_planks", {
description = treedesc.." Planks",
tiles = {"moretrees_"..treename.."_wood.png"},
is_ground_content = true,
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("moretrees:"..treename.."_sapling", {
description = treedesc.." Sapling",
drawtype = "plantlike",
tiles = {"moretrees_"..treename.."_sapling.png"},
inventory_image = "moretrees_"..treename.."_sapling.png",
paramtype = "light",
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},
sounds = default.node_sound_defaults(),
})
-- player will get a sapling with 1/100 chance
-- player will get leaves only if he/she gets no saplings,
-- this is because max_items is 1
minetest.register_node("moretrees:"..treename.."_leaves", {
description = treedesc.." Leaves",
drawtype = "allfaces_optional",
tiles = { "moretrees_"..treename.."_leaves.png" },
paramtype = "light",
groups = {snappy=3, flammable=2, leaves=1, moretrees_leaves=1},
sounds = default.node_sound_leaves_defaults(),
drop = {
max_items = 1,
items = {
{items = {"moretrees:"..treename.."_sapling"}, rarity = 100 },
{items = {"moretrees:"..treename.."_leaves"} }
}
},
})
end
if (fruit ~= nil) then
minetest.register_node("moretrees:"..fruit, {
description = fruitdesc,
drawtype = "plantlike",
tiles = { "moretrees_"..fruit..".png" },
inventory_image = "moretrees_"..fruit..".png^[transformR180",
wield_image = "moretrees_"..fruit..".png^[transformR180",
visual_scale = vscale,
paramtype = "light",
sunlight_propagates = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = selbox
},
groups = {fleshy=3,dig_immediate=3,flammable=2, attached_node=1},
sounds = default.node_sound_defaults(),
})
end
table.insert(moretrees.avoidnodes, "moretrees:"..treename.."_trunk")
end
-- Extra leaves for jungle trees:
local jungleleaves = {"green","yellow","red"}
local jungleleavesnames = {"Green", "Yellow", "Red"}
for color = 1, 3 do
local leave_name = "moretrees:jungletree_leaves_"..jungleleaves[color]
minetest.register_node(leave_name, {
description = "Jungle Tree Leaves ("..jungleleavesnames[color]..")",
drawtype = "allfaces_optional",
tiles = {"moretrees_jungletree_leaves_"..jungleleaves[color]..".png"},
paramtype = "light",
groups = {snappy=3, flammable=2, leaves=1, moretrees_leaves=1},
drop = {
max_items = 1,
items = {
{items = {'moretrees:jungletree_sapling'}, rarity = 100 },
{items = {"moretrees:jungletree_leaves_"..jungleleaves[color]} }
}
},
sounds = default.node_sound_leaves_defaults(),
})
end
-- sideways jungle tree trunk:
minetest.register_node("moretrees:jungletree_trunk_sideways", {
description = "Sideways Jungle Tree Trunk",
tiles = {
"default_jungletree.png^[transformR90",
"default_jungletree.png^[transformR90",
"default_jungletree_top.png",
"default_jungletree_top.png",
"default_jungletree.png^[transformR90",
"default_jungletree.png^[transformR90"
},
is_ground_content = true,
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
sounds = default.node_sound_wood_defaults(),
paramtype2 = "facedir",
})
-- Extra needles for firs
minetest.register_node("moretrees:fir_leaves_bright", {
drawtype = "allfaces_optional",
description = "Douglas Fir Leaves (Bright)",
tile_images = { "moretrees_fir_leaves_bright.png" },
paramtype = "light",
groups = {snappy=3, flammable=2, leaves=1, moretrees_leaves=1 },
drop = {
max_items = 1,
items = {
{items = {'moretrees:fir_sapling'}, rarity = 100 },
{items = {'moretrees:fir_leaves'} }
}
},
sounds = default.node_sound_leaves_defaults()
})
if moretrees.enable_redefine_apple then
minetest.register_node(":default:apple", {
description = "Apple",
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"default_apple.png"},
inventory_image = "default_apple.png",
paramtype = "light",
sunlight_propagates = true,
walkable = 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,attached_node=1},
on_use = minetest.item_eat(4),
sounds = default.node_sound_defaults(),
})
end
if moretrees.enable_replace_default_trees then
minetest.register_node(":default:tree", {
description = "Beech Trunk",
tiles = {"moretrees_beech_trunk_top.png", "moretrees_beech_trunk_top.png", "moretrees_beech_trunk.png"},
groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node(":default:leaves", {
description = "Beech Leaves",
drawtype = "allfaces_optional",
visual_scale = 1.3,
tiles = {"moretrees_beech_leaves.png"},
paramtype = "light",
groups = {snappy=3, leafdecay=3, flammable=2, leaves=1},
drop = {
max_items = 1,
items = {
{
-- player will get sapling with 1/20 chance
items = {'default:sapling'},
rarity = 20,
},
{
-- player will get leaves only if he get no saplings,
-- this is because max_items is 1
items = {'default:leaves'},
}
}
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node(":default:wood", {
description = "Beech Planks",
tiles = {"moretrees_beech_wood.png"},
groups = {choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node(":default:sapling", {
description = "Beech Sapling",
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"moretrees_beech_sapling.png"},
inventory_image = "moretrees_beech_sapling.png",
wield_image = "moretrees_beech_sapling.png",
paramtype = "light",
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},
sounds = default.node_sound_defaults(),
})
end
minetest.register_node("moretrees:beech_trunk_sideways", {
description = "Sideways Beech Trunk",
tiles = {
"moretrees_beech_trunk.png^[transformR90",
"moretrees_beech_trunk.png^[transformR90",
"moretrees_beech_trunk_top.png",
"moretrees_beech_trunk_top.png",
"moretrees_beech_trunk.png^[transformR90",
"moretrees_beech_trunk.png^[transformR90"
},
is_ground_content = true,
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
sounds = default.node_sound_wood_defaults(),
paramtype2 = "facedir",
})
table.insert(moretrees.avoidnodes, "default:jungletree")
table.insert(moretrees.avoidnodes, "moretrees:jungletree_trunk")
table.insert(moretrees.avoidnodes, "moretrees:fir_trunk")
-- For compatibility with old nodes and recently-changed nodes.
minetest.register_alias("moretrees:beech_trunk", "default:tree")
minetest.register_alias("moretrees:beech_leaves", "default:leaves")
minetest.register_alias("moretrees:beech_planks", "default:wood")
minetest.register_alias("moretrees:beech_sapling", "default:sapling")
minetest.register_alias("moretrees:jungletree_trunk", "default:jungletree")
minetest.register_alias("moretrees:jungletree_planks", "default:junglewood")
minetest.register_alias("moretrees:jungletree_sapling", "default:junglesapling")
minetest.register_alias("jungletree:sapling", "default:junglesapling")
minetest.register_alias("jungletree:leaves_green", "moretrees:jungletree_leaves_green")
minetest.register_alias("jungletree:leaves_red", "moretrees:jungletree_leaves_red")
minetest.register_alias("jungletree:leaves_yellow", "moretrees:jungletree_leaves_yellow")
minetest.register_alias("moretrees:conifer_trunk", "moretrees:fir_trunk")
minetest.register_alias("moretrees:conifer_trunk_sideways", "moretrees:fir_trunk_sideways")
minetest.register_alias("moretrees:conifer_leaves", "moretrees:fir_leaves")
minetest.register_alias("moretrees:conifer_leaves_bright", "moretrees:fir_leaves_bright")
minetest.register_alias("moretrees:conifer_sapling", "moretrees:fir_sapling")
minetest.register_alias("conifers:trunk", "moretrees:fir_trunk")
minetest.register_alias("conifers:trunk_reversed", "moretrees:fir_trunk_sideways")
minetest.register_alias("conifers:leaves", "moretrees:fir_leaves")
minetest.register_alias("conifers:leaves_special", "moretrees:fir_leaves_bright")
minetest.register_alias("conifers:sapling", "moretrees:fir_sapling")