2014-11-09 22:17:41 +03:00
|
|
|
-- Register Saplings
|
2015-07-25 18:45:29 +03:00
|
|
|
ethereal.register_sapling = function(name, desc, texture)
|
|
|
|
|
|
|
|
minetest.register_node(name .. "_sapling", {
|
|
|
|
description = desc .. " Tree Sapling",
|
|
|
|
drawtype = "plantlike",
|
|
|
|
visual_scale = 1.0,
|
|
|
|
tiles = {texture .. "_sapling.png"},
|
|
|
|
inventory_image = texture .. "_sapling.png",
|
|
|
|
paramtype = "light",
|
|
|
|
sunlight_propagates = true,
|
|
|
|
is_ground_content = false,
|
|
|
|
walkable = false,
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5}
|
|
|
|
},
|
|
|
|
groups = {
|
|
|
|
snappy = 2, dig_immediate = 3, flammable = 2,
|
|
|
|
ethereal_sapling = 1, attached_node = 1
|
|
|
|
},
|
|
|
|
sounds = default.node_sound_defaults(),
|
|
|
|
})
|
2014-11-09 22:17:41 +03:00
|
|
|
end
|
|
|
|
|
2015-07-25 18:45:29 +03:00
|
|
|
ethereal.register_sapling("ethereal:willow", "Willow", "willow")
|
|
|
|
ethereal.register_sapling("ethereal:yellow_tree", "Healing", "yellow_tree")
|
|
|
|
ethereal.register_sapling("ethereal:tree", "Apple", "ethereal_tree")
|
|
|
|
ethereal.register_sapling("ethereal:jungle_tree","Jungle", "ethereal_jungle_tree")
|
|
|
|
ethereal.register_sapling("ethereal:pine_tree", "Pine", "ethereal_pine_tree")
|
|
|
|
ethereal.register_sapling("ethereal:big_tree", "Big", "ethereal_big_tree")
|
|
|
|
ethereal.register_sapling("ethereal:banana_tree", "Banana", "banana_tree")
|
|
|
|
ethereal.register_sapling("ethereal:frost_tree", "Frost", "ethereal_frost_tree")
|
|
|
|
ethereal.register_sapling("ethereal:gray_tree", "Gray", "ethereal_gray_tree")
|
|
|
|
ethereal.register_sapling("ethereal:mushroom", "Mushroom", "ethereal_mushroom")
|
|
|
|
ethereal.register_sapling("ethereal:palm", "Palm", "moretrees_palm")
|
|
|
|
ethereal.register_sapling("ethereal:redwood", "Redwood", "redwood")
|
|
|
|
ethereal.register_sapling("ethereal:orange_tree", "Orange", "orange_tree")
|
|
|
|
ethereal.register_sapling("ethereal:acacia", "Acacia", "moretrees_acacia")
|
|
|
|
|
2015-04-25 14:41:36 +03:00
|
|
|
ethereal.add_tree = function (pos, ofx, ofz, schem)
|
|
|
|
-- check for schematic
|
|
|
|
if not schem then
|
|
|
|
print ("Schematic not found")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
-- remove sapling and place schematic
|
2015-07-04 14:22:39 +03:00
|
|
|
minetest.set_node(pos, {name = "air"})
|
|
|
|
minetest.place_schematic(
|
|
|
|
{x = pos.x - ofx, y = pos.y, z =pos.z - ofz},
|
|
|
|
schem, "random", {}, false
|
|
|
|
)
|
2015-04-25 14:41:36 +03:00
|
|
|
end
|
|
|
|
|
2015-07-25 18:45:29 +03:00
|
|
|
local path = minetest.get_modpath("ethereal").."/schematics/"
|
|
|
|
|
2015-07-24 13:11:22 +03:00
|
|
|
ethereal.grow_sapling = function (pos, node)
|
|
|
|
|
|
|
|
local under = minetest.get_node_or_nil({x = pos.x, y = pos.y - 1, z = pos.z})
|
|
|
|
if under then under = under.name else return end
|
|
|
|
|
|
|
|
-- Check if Sapling is growing on correct substrate
|
2015-07-25 18:45:29 +03:00
|
|
|
if node.name == "ethereal:yellow_tree_sapling"
|
|
|
|
and under == "default:dirt_with_snow" then
|
|
|
|
ethereal.add_tree(pos, 4, 4, path .. "yellowtree.mts")
|
|
|
|
|
|
|
|
elseif node.name == "ethereal:tree_sapling"
|
|
|
|
and under == "ethereal:green_dirt" then
|
2015-07-24 13:11:22 +03:00
|
|
|
ethereal.add_tree(pos, 1, 1, ethereal.appletree)
|
2015-07-25 18:45:29 +03:00
|
|
|
|
|
|
|
elseif node.name == "ethereal:jungle_tree_sapling"
|
|
|
|
and under == "ethereal:jungle_dirt" then
|
|
|
|
ethereal.add_tree(pos, 6, 6, path .. "jungletree.mts")
|
|
|
|
|
|
|
|
elseif node.name == "ethereal:pine_tree_sapling"
|
|
|
|
and under == "ethereal:cold_dirt" then
|
|
|
|
ethereal.add_tree(pos, 3, 3, path .. "pinetree.mts")
|
|
|
|
|
|
|
|
elseif node.name == "ethereal:big_tree_sapling"
|
|
|
|
and under == "ethereal:green_dirt" then
|
|
|
|
ethereal.add_tree(pos, 4, 4, path .. "bigtree.mts")
|
|
|
|
|
|
|
|
elseif node.name == "ethereal:banana_tree_sapling"
|
|
|
|
and under == "ethereal:grove_dirt" then
|
2015-07-24 13:11:22 +03:00
|
|
|
ethereal.add_tree(pos, 3, 3, ethereal.bananatree)
|
2015-07-25 18:45:29 +03:00
|
|
|
|
|
|
|
elseif node.name == "ethereal:frost_tree_sapling"
|
|
|
|
and under == "ethereal:crystal_dirt" then
|
|
|
|
ethereal.add_tree(pos, 4, 4, path .. "frosttrees.mts")
|
|
|
|
|
|
|
|
elseif node.name == "ethereal:gray_tree_sapling"
|
|
|
|
and under == "ethereal:gray_dirt" then
|
|
|
|
ethereal.add_tree(pos, 2, 2, path .. "graytrees.mts")
|
|
|
|
|
|
|
|
elseif node.name == "ethereal:mushroom_sapling"
|
|
|
|
and under == "ethereal:mushroom_dirt" then
|
|
|
|
ethereal.add_tree(pos, 4, 4, path .. "mushroomone.mts")
|
|
|
|
|
|
|
|
elseif node.name == "ethereal:palm_sapling"
|
|
|
|
and under == "default:sand" then
|
|
|
|
ethereal.add_tree(pos, 4, 4, path .. "palmtree.mts")
|
|
|
|
|
|
|
|
elseif node.name == "ethereal:willow_sapling"
|
|
|
|
and under == "ethereal:gray_dirt" then
|
|
|
|
ethereal.add_tree(pos, 5, 5, path .. "willow.mts")
|
|
|
|
|
|
|
|
elseif node.name == "ethereal:redwood_sapling"
|
|
|
|
and under == "bakedclay:red" then
|
|
|
|
ethereal.add_tree(pos, 9, 9, path .. "redwood.mts")
|
|
|
|
|
|
|
|
elseif node.name == "ethereal:orange_tree_sapling"
|
|
|
|
and under == "ethereal:prairie_dirt" then
|
2015-07-24 13:11:22 +03:00
|
|
|
ethereal.add_tree(pos, 1, 1, ethereal.orangetree)
|
2015-07-25 18:45:29 +03:00
|
|
|
|
|
|
|
elseif node.name == "ethereal:acacia_sapling"
|
|
|
|
and under == "default:desert_sand" then
|
|
|
|
ethereal.add_tree(pos, 5, 5, path .. "acaciatree.mts")
|
2015-07-24 13:11:22 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-11-09 22:17:41 +03:00
|
|
|
-- Grow saplings
|
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = {"group:ethereal_sapling"},
|
2015-04-10 17:38:53 +03:00
|
|
|
interval = 10,
|
|
|
|
chance = 50,
|
2014-11-09 22:17:41 +03:00
|
|
|
action = function(pos, node)
|
2015-07-24 13:11:22 +03:00
|
|
|
ethereal.grow_sapling(pos, node)
|
2014-11-09 22:17:41 +03:00
|
|
|
end,
|
2015-07-04 14:22:39 +03:00
|
|
|
})
|