realtest/mods/trees/registration.lua

392 lines
11 KiB
Lua
Raw Normal View History

2012-11-16 13:39:39 +06:00
realtest.registered_trees = {}
2012-11-23 14:58:00 +06:00
realtest.registered_trees_list = {}
2012-11-16 13:39:39 +06:00
function realtest.register_tree(name, TreeDef)
local tree = {
name = name,
description = TreeDef.description or "",
grounds = TreeDef.grounds or {"default:dirt","default:dirt_with_grass"},
leaves = TreeDef.leaves or {},
height = TreeDef.height or function() return 10 end,
radius = TreeDef.radius or 5,
textures = TreeDef.textures or {{},"","","",""},
2012-11-16 16:36:11 +06:00
grow_interval = TreeDef.grow_interval or 60,
grow_chance = TreeDef.grow_chance or 20,
grow_light = TreeDef.grow_light or 8
2012-11-16 13:39:39 +06:00
}
realtest.registered_trees[name] = tree
2012-11-23 14:58:00 +06:00
table.insert(realtest.registered_trees_list, tree.name)
2012-11-16 13:39:39 +06:00
minetest.register_node(tree.name.."_planks", {
description = tree.description.." Planks",
tiles = {tree.textures[3]},
2012-11-25 19:23:02 +06:00
groups = {planks=1,snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3,drop_on_dig=1},
2012-11-16 13:39:39 +06:00
sounds = default.node_sound_wood_defaults(),
})
minetest.register_craftitem(tree.name.."_stick", {
description = tree.description.." Stick",
inventory_image = tree.textures[4],
groups = {stick=1},
})
minetest.register_node(tree.name.."_sapling", {
description = tree.description.." Sapling",
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {tree.textures[5]},
inventory_image = tree.textures[5],
wield_image = tree.textures[5],
paramtype = "light",
walkable = false,
2012-11-16 16:36:11 +06:00
groups = {snappy=2,dig_immediate=3,flammable=2,dropping_node=1},
2012-11-16 13:39:39 +06:00
sounds = default.node_sound_defaults(),
})
2012-11-25 14:07:38 +06:00
minetest.register_craftitem(tree.name.."_plank", {
description = tree.description.." Plank",
inventory_image = tree.textures[7],
2012-11-25 19:23:02 +06:00
group = {plank=1},
2012-11-25 14:07:38 +06:00
})
2012-11-25 19:42:16 +06:00
minetest.register_node(tree.name.."_log", {
2012-11-23 15:48:06 +06:00
description = tree.description.." Log",
2012-11-25 14:07:38 +06:00
tiles = tree.textures[1],
2012-11-23 15:48:06 +06:00
inventory_image = tree.textures[6],
2012-11-25 14:07:38 +06:00
wield_image = tree.textures[6],
2012-11-25 19:23:02 +06:00
groups = {log=1,snappy=1,choppy=2,flammable=2,dropping_node=1,drop_on_dig=1},
2012-11-25 14:07:38 +06:00
sounds = default.node_sound_wood_defaults(),
drop = tree.name.."_plank 4",
drop_on_dropping = tree.name.."_log",
drawtype = "nodebox",
paramtype = "light",
node_box = {
type = "fixed",
fixed = {
{-0.4,-0.5,-0.4,0.4,0.5,0.4},
},
},
selection_box = {
type = "fixed",
fixed = {
{-0.4,-0.5,-0.4,0.4,0.5,0.4},
},
},
2012-11-23 15:48:06 +06:00
})
2012-11-16 13:39:39 +06:00
minetest.register_node(tree.name.."_leaves", {
description = tree.description.." Leaves",
drawtype = "allfaces_optional",
visual_scale = 1.3,
tiles = {tree.textures[2]},
paramtype = "light",
groups = {snappy=3, leafdecay=3, flammable=2,drop_on_dig=1,leaves=1},
2012-11-16 13:39:39 +06:00
drop = {
max_items = 1,
items = {
{
items = {tree.name..'_sapling'},
2012-11-16 20:14:15 +06:00
rarity = 30,
2012-11-16 13:39:39 +06:00
},
{
items = {tree.name..'_stick'},
2012-11-23 14:20:18 +06:00
rarity = 10,
2012-11-16 13:39:39 +06:00
},
{
items = {},
2012-11-16 20:14:15 +06:00
}
2012-11-16 13:39:39 +06:00
}
},
sounds = default.node_sound_leaves_defaults(),
walkable = false,
climbable = true,
})
2012-11-16 16:36:11 +06:00
2012-11-23 14:20:18 +06:00
minetest.register_node(tree.name.."_trunk", {
2012-11-16 20:14:15 +06:00
description = tree.description.." Trunk",
tiles = tree.textures[1],
groups = {tree=1,snappy=1,choppy=2,flammable=2,dropping_node=1,drop_on_dig=1},
2012-11-16 20:14:15 +06:00
sounds = default.node_sound_wood_defaults(),
2012-11-23 15:48:06 +06:00
drop = tree.name.."_log",
2012-11-16 20:14:15 +06:00
drawtype = "nodebox",
paramtype = "light",
node_box = {
type = "fixed",
fixed = {
{-0.4,-0.5,-0.4,0.4,0.5,0.4},
},
},
selection_box = {
type = "fixed",
fixed = {
{-0.4,-0.5,-0.4,0.4,0.5,0.4},
},
},
after_dig_node = function(pos, oldnode, oldmetadata, digger)
for i = 1,#tree.leaves do
local p = {x=pos.x+tree.leaves[i][1], y=pos.y+tree.leaves[i][2], z=pos.z+tree.leaves[i][3]}
if minetest.env:get_node(p).name == tree.name.."_leaves" then
minetest.env:dig_node(p)
end
end
end,
})
2012-11-26 18:13:18 +06:00
minetest.register_node(tree.name.."_fence", {
description = tree.description.." Fence",
drawtype = "fencelike",
tiles = {tree.textures[3]},
paramtype = "light",
is_ground_content = true,
selection_box = {
type = "fixed",
fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
},
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=2},
sounds = default.node_sound_wood_defaults(),
})
2012-11-27 14:50:01 +06:00
minetest.register_node(tree.name.."_stair", {
description = tree.description.." Stair",
drawtype = "nodebox",
tiles = {tree.textures[3]},
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = true,
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=2},
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
{-0.5, 0, 0, 0.5, 0.5, 0.5},
},
},
})
minetest.register_node(tree.name.."_slab", {
description = tree.description.." Slab",
drawtype = "nodebox",
tiles = {tree.textures[3]},
paramtype = "light",
is_ground_content = true,
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=2},
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
})
minetest.register_craft({
output = tree.name.."_slab",
recipe = {
{tree.name.."_plank", tree.name.."_plank", tree.name.."_plank"},
},
})
minetest.register_craft({
output = tree.name.."_planks",
recipe = {
{tree.name.."_slab"},
{tree.name.."_slab"},
},
})
minetest.register_craft({
output = tree.name.."_stair 2",
recipe = {
{tree.name.."_plank", "", ""},
{tree.name.."_plank", tree.name.."_plank", ""},
{tree.name.."_plank", tree.name.."_plank", tree.name.."_plank"},
},
})
minetest.register_craft({
output = tree.name.."_stair 2",
recipe = {
{"", "", tree.name.."_plank"},
{"", tree.name.."_plank", tree.name.."_plank"},
{tree.name.."_plank", tree.name.."_plank", tree.name.."_plank"},
},
})
2012-11-26 18:13:18 +06:00
minetest.register_craft({
output = tree.name.."_fence 2",
recipe = {
{tree.name.."_plank", tree.name.."_plank", tree.name.."_plank"},
{tree.name.."_plank", tree.name.."_plank", tree.name.."_plank"},
}
})
2012-11-25 19:42:16 +06:00
minetest.register_craft({
output = "default:sign_wall",
recipe = {
{tree.name.."_plank", tree.name.."_plank", tree.name.."_plank"},
{tree.name.."_plank", tree.name.."_plank", tree.name.."_plank"},
2012-11-25 21:05:43 +06:00
{"", "group:stick", ""},
2012-11-25 19:42:16 +06:00
}
})
minetest.register_craft({
output = "default:chest",
recipe = {
{tree.name.."_plank", tree.name.."_plank", tree.name.."_plank"},
{tree.name.."_plank", "", tree.name.."_plank"},
{tree.name.."_plank", tree.name.."_plank", tree.name.."_plank"},
}
})
2012-11-25 21:05:43 +06:00
for i,metal in ipairs(metals.list) do
minetest.register_craft({
output = "default:chest_locked",
recipe = {
{tree.name.."_plank", tree.name.."_plank", tree.name.."_plank"},
{tree.name.."_plank", "metals:"..metal.."_lock", tree.name.."_plank"},
{tree.name.."_plank", tree.name.."_plank", tree.name.."_plank"},
}
})
end
2012-11-25 19:42:16 +06:00
minetest.register_craft({
output = tree.name.."_planks",
recipe = {
{tree.name.."_plank",tree.name.."_plank"},
{tree.name.."_plank",tree.name.."_plank"}
}
})
minetest.register_craft({
output = tree.name.."_plank 4",
recipe = {{tree.name.."_planks"}}
})
2012-11-27 14:50:01 +06:00
minetest.register_craft({
type = "fuel",
recipe = tree.name.."_stair",
burntime = 3.5,
})
realtest.add_bonfire_fuel(tree.name.."_stair")
minetest.register_craft({
type = "fuel",
recipe = tree.name.."_slab",
burntime = 3.5,
})
realtest.add_bonfire_fuel(tree.name.."_slab")
2012-11-25 19:42:16 +06:00
minetest.register_craft({
type = "fuel",
recipe = tree.name.."_plank",
burntime = 2,
})
2012-11-25 21:59:06 +06:00
realtest.add_bonfire_fuel(tree.name.."_plank")
2012-11-25 19:42:16 +06:00
minetest.register_craft({
type = "fuel",
recipe = tree.name.."_planks",
burntime = 7,
})
2012-11-25 21:59:06 +06:00
realtest.add_bonfire_fuel(tree.name.."_planks")
2012-11-25 19:42:16 +06:00
minetest.register_craft({
type = "fuel",
recipe = tree.name.."_log",
burntime = 7,
})
2012-11-25 21:59:06 +06:00
realtest.add_bonfire_fuel(tree.name.."_log")
2012-11-25 19:42:16 +06:00
minetest.register_craft({
type = "fuel",
recipe = tree.name.."_stick",
burntime = 1,
})
2012-11-25 21:59:06 +06:00
realtest.add_bonfire_fuel(tree.name.."_stick")
2012-11-25 19:42:16 +06:00
minetest.register_craft({
type = "fuel",
recipe = tree.name.."_sapling",
burntime = 5,
})
2012-11-25 21:59:06 +06:00
realtest.add_bonfire_fuel(tree.name.."_sapling")
minetest.register_craft({
type="cooking",
output="default:coal_lump",
recipe=tree.name.."_log",
})
2012-11-25 19:42:16 +06:00
2012-11-16 16:36:11 +06:00
minetest.register_abm({
nodenames = {tree.name.."_sapling"},
neighbors = tree.grounds,
interval = tree.grow_interval,
chance = tree.grow_chance,
action = function(pos, node)
if not minetest.env:get_node_light(pos) then
return
end
if minetest.env:get_node_light(pos) >= tree.grow_light then
trees.make_tree(pos, tree.name)
end
end,
})
2012-11-16 13:39:39 +06:00
end
realtest.register_tree("trees:ash", {
description = "Ash",
leaves = trees.gen_lists.ash,
height = function()
return 4 + math.random(4)
end,
textures = {{"trees_ash_trunk_top.png", "trees_ash_trunk_top.png", "trees_ash_trunk.png"},"trees_ash_leaves.png",
2012-11-25 14:07:38 +06:00
"trees_ash_planks.png", "trees_ash_stick.png", "trees_ash_sapling.png", "trees_ash_log.png", "trees_ash_plank.png"}
2012-11-16 13:39:39 +06:00
})
realtest.register_tree("trees:aspen", {
description = "Aspen",
leaves = trees.gen_lists.aspen,
height = function()
return 10 + math.random(4)
end,
textures = {{"trees_aspen_trunk_top.png", "trees_aspen_trunk_top.png", "trees_aspen_trunk.png"},"trees_aspen_leaves.png",
2012-11-25 14:07:38 +06:00
"trees_aspen_planks.png", "trees_aspen_stick.png", "trees_aspen_sapling.png", "trees_aspen_log.png", "trees_aspen_plank.png"}
2012-11-16 13:39:39 +06:00
})
realtest.register_tree("trees:birch", {
description = "Birch",
leaves = trees.gen_lists.birch,
height = function()
return 10 + math.random(4)
end,
textures = {{"trees_birch_trunk_top.png", "trees_birch_trunk_top.png", "trees_birch_trunk.png"},"trees_birch_leaves.png",
2012-11-25 14:07:38 +06:00
"trees_birch_planks.png", "trees_birch_stick.png", "trees_birch_sapling.png", "trees_birch_log.png", "trees_birch_plank.png"}
2012-11-16 13:39:39 +06:00
})
realtest.register_tree("trees:mapple", {
description = "Mapple",
leaves = trees.gen_lists.mapple,
height = function()
return 7 + math.random(5)
end,
textures = {{"trees_mapple_trunk_top.png", "trees_mapple_trunk_top.png", "trees_mapple_trunk.png"},"trees_mapple_leaves.png",
2012-11-25 14:07:38 +06:00
"trees_mapple_planks.png", "trees_mapple_stick.png", "trees_mapple_sapling.png", "trees_mapple_log.png", "trees_mapple_plank.png"}
2012-11-16 13:39:39 +06:00
})
realtest.register_tree("trees:chestnut", {
description = "Chestnut",
leaves = trees.gen_lists.chestnut,
height = function()
return 9 + math.random(2)
end,
radius = 10,
textures = {{"trees_chestnut_trunk_top.png", "trees_chestnut_trunk_top.png", "trees_chestnut_trunk.png"},"trees_chestnut_leaves.png",
2012-11-25 14:07:38 +06:00
"trees_chestnut_planks.png", "trees_chestnut_stick.png", "trees_chestnut_sapling.png", "trees_chestnut_log.png", "trees_chestnut_plank.png"}
2012-11-16 13:39:39 +06:00
})
realtest.register_tree("trees:pine", {
description = "Pine",
leaves = trees.gen_lists.pine,
height = function()
return 13 + math.random(4)
end,
2012-11-23 15:48:06 +06:00
radius = 8,
2012-11-16 13:39:39 +06:00
textures = {{"trees_pine_trunk_top.png", "trees_pine_trunk_top.png", "trees_pine_trunk.png"},"trees_pine_leaves.png",
2012-11-25 14:07:38 +06:00
"trees_pine_planks.png", "trees_pine_stick.png", "trees_pine_sapling.png", "trees_pine_log.png", "trees_pine_plank.png"}
2012-11-16 13:39:39 +06:00
})