2016-05-17 23:40:05 +03:00
|
|
|
|
2016-06-09 17:08:34 +03:00
|
|
|
local S = ethereal.intllib
|
|
|
|
|
2016-05-17 23:40:05 +03:00
|
|
|
-- Bamboo Sprout
|
|
|
|
minetest.register_node("ethereal:bamboo_sprout", {
|
2016-06-09 17:08:34 +03:00
|
|
|
description = S("Bamboo Sprout"),
|
2016-05-17 23:40:05 +03:00
|
|
|
drawtype = "plantlike",
|
|
|
|
tiles = {"bamboo_sprout.png"},
|
|
|
|
inventory_image = "bamboo_sprout.png",
|
|
|
|
wield_image = "bamboo_sprout.png",
|
|
|
|
paramtype = "light",
|
|
|
|
sunlight_propagates = true,
|
|
|
|
walkable = false,
|
|
|
|
groups = {
|
2018-03-12 20:04:13 +03:00
|
|
|
food_bamboo_sprout = 1, snappy = 3, attached_node = 1, flammable = 2,
|
2018-03-25 20:52:22 +03:00
|
|
|
dig_immediate = 3, ethereal_sapling = 1, sapling = 1,
|
2016-05-17 23:40:05 +03:00
|
|
|
},
|
|
|
|
sounds = default.node_sound_defaults(),
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
2016-12-22 00:23:13 +03:00
|
|
|
fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 0, 4 / 16}
|
2016-05-17 23:40:05 +03:00
|
|
|
},
|
2017-01-08 12:56:09 +03:00
|
|
|
on_use = minetest.item_eat(2),
|
2016-07-14 15:12:44 +03:00
|
|
|
grown_height = 11,
|
2016-05-17 23:40:05 +03:00
|
|
|
})
|
|
|
|
|
2014-11-09 22:17:41 +03:00
|
|
|
-- Register Saplings
|
2016-07-14 15:12:44 +03:00
|
|
|
ethereal.register_sapling = function(name, desc, texture, height)
|
2015-07-25 18:45:29 +03:00
|
|
|
|
|
|
|
minetest.register_node(name .. "_sapling", {
|
2016-06-09 17:08:34 +03:00
|
|
|
description = S(desc .. " Tree Sapling"),
|
2015-07-25 18:45:29 +03:00
|
|
|
drawtype = "plantlike",
|
2016-05-17 23:40:05 +03:00
|
|
|
tiles = {texture .. ".png"},
|
|
|
|
inventory_image = texture .. ".png",
|
|
|
|
wield_image = texture .. ".png",
|
2015-07-25 18:45:29 +03:00
|
|
|
paramtype = "light",
|
|
|
|
sunlight_propagates = true,
|
|
|
|
is_ground_content = false,
|
|
|
|
walkable = false,
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
2016-12-22 00:23:13 +03:00
|
|
|
fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
|
2015-07-25 18:45:29 +03:00
|
|
|
},
|
|
|
|
groups = {
|
|
|
|
snappy = 2, dig_immediate = 3, flammable = 2,
|
2017-01-08 12:56:09 +03:00
|
|
|
ethereal_sapling = 1, attached_node = 1, sapling = 1
|
2015-07-25 18:45:29 +03:00
|
|
|
},
|
2016-12-22 00:23:13 +03:00
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
2016-07-14 15:12:44 +03:00
|
|
|
grown_height = height,
|
2015-07-25 18:45:29 +03:00
|
|
|
})
|
2014-11-09 22:17:41 +03:00
|
|
|
end
|
|
|
|
|
2016-07-14 15:12:44 +03:00
|
|
|
ethereal.register_sapling("ethereal:willow", "Willow", "willow_sapling", 14)
|
|
|
|
ethereal.register_sapling("ethereal:yellow_tree", "Healing", "yellow_tree_sapling", 19)
|
|
|
|
ethereal.register_sapling("ethereal:big_tree", "Big", "ethereal_big_tree_sapling", 7)
|
|
|
|
ethereal.register_sapling("ethereal:banana_tree", "Banana", "banana_tree_sapling", 8)
|
|
|
|
ethereal.register_sapling("ethereal:frost_tree", "Frost", "ethereal_frost_tree_sapling", 19)
|
|
|
|
ethereal.register_sapling("ethereal:mushroom", "Mushroom", "ethereal_mushroom_sapling", 11)
|
|
|
|
ethereal.register_sapling("ethereal:palm", "Palm", "moretrees_palm_sapling", 9)
|
|
|
|
ethereal.register_sapling("ethereal:redwood", "Redwood", "redwood_sapling", 31)
|
|
|
|
ethereal.register_sapling("ethereal:orange_tree", "Orange", "orange_tree_sapling", 6)
|
|
|
|
ethereal.register_sapling("ethereal:birch", "Birch", "moretrees_birch_sapling", 7)
|
2016-05-17 23:40:05 +03:00
|
|
|
|
|
|
|
ethereal.add_tree = function (pos, ofx, ofy, ofz, schem)
|
2015-04-25 14:41:36 +03:00
|
|
|
-- check for schematic
|
|
|
|
if not schem then
|
2016-06-09 17:08:34 +03:00
|
|
|
print (S("Schematic not found"))
|
2015-04-25 14:41:36 +03:00
|
|
|
return
|
|
|
|
end
|
|
|
|
-- remove sapling and place schematic
|
2016-01-09 15:25:33 +03:00
|
|
|
minetest.swap_node(pos, {name = "air"})
|
2015-07-04 14:22:39 +03:00
|
|
|
minetest.place_schematic(
|
2016-05-17 23:40:05 +03:00
|
|
|
{x = pos.x - ofx, y = pos.y - ofy, z = pos.z - ofz},
|
|
|
|
schem, 0, nil, 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/"
|
|
|
|
|
2016-05-17 23:40:05 +03:00
|
|
|
-- grow tree functions
|
|
|
|
function ethereal.grow_yellow_tree(pos)
|
|
|
|
ethereal.add_tree(pos, 4, 0, 4, path .. "yellowtree.mts")
|
|
|
|
end
|
|
|
|
|
|
|
|
function ethereal.grow_big_tree(pos)
|
|
|
|
ethereal.add_tree(pos, 4, 0, 4, path .. "bigtree.mts")
|
|
|
|
end
|
|
|
|
|
|
|
|
function ethereal.grow_banana_tree(pos)
|
|
|
|
ethereal.add_tree(pos, 3, 0, 3, ethereal.bananatree)
|
|
|
|
end
|
|
|
|
|
|
|
|
function ethereal.grow_frost_tree(pos)
|
|
|
|
ethereal.add_tree(pos, 4, 0, 4, path .. "frosttrees.mts")
|
|
|
|
end
|
|
|
|
|
|
|
|
function ethereal.grow_mushroom_tree(pos)
|
|
|
|
ethereal.add_tree(pos, 4, 0, 4, path .. "mushroomone.mts")
|
|
|
|
end
|
|
|
|
|
|
|
|
function ethereal.grow_palm_tree(pos)
|
|
|
|
ethereal.add_tree(pos, 4, 0, 4, path .. "palmtree.mts")
|
|
|
|
end
|
|
|
|
|
|
|
|
function ethereal.grow_willow_tree(pos)
|
|
|
|
ethereal.add_tree(pos, 5, 0, 5, path .. "willow.mts")
|
|
|
|
end
|
|
|
|
|
|
|
|
function ethereal.grow_redwood_tree(pos)
|
|
|
|
if math.random(1, 2) == 1 then
|
|
|
|
ethereal.add_tree(pos, 9, 3, 9, path .. "redwood.mts") -- shinji
|
|
|
|
else
|
|
|
|
ethereal.add_tree(pos, 8, 6, 8, path .. "redwood_tree.mts") -- iska
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function ethereal.grow_orange_tree(pos)
|
|
|
|
ethereal.add_tree(pos, 1, 0, 1, ethereal.orangetree)
|
|
|
|
end
|
|
|
|
|
|
|
|
function ethereal.grow_bamboo_tree(pos)
|
|
|
|
ethereal.add_tree(pos, 1, 0, 1, ethereal.bambootree)
|
|
|
|
end
|
|
|
|
|
|
|
|
function ethereal.grow_birch_tree(pos)
|
|
|
|
ethereal.add_tree(pos, 2, 0, 2, ethereal.birchtree)
|
|
|
|
end
|
|
|
|
|
2016-07-14 15:12:44 +03:00
|
|
|
-- check if sapling has enough height room to grow
|
|
|
|
local function enough_height(pos, height)
|
|
|
|
|
|
|
|
local nod = minetest.line_of_sight(
|
|
|
|
{x = pos.x, y = pos.y + 1, z = pos.z},
|
|
|
|
{x = pos.x, y = pos.y + height, z = pos.z})
|
|
|
|
|
|
|
|
if not nod then
|
|
|
|
return false -- obstructed
|
|
|
|
else
|
|
|
|
return true -- can grow
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-07-24 13:11:22 +03:00
|
|
|
ethereal.grow_sapling = function (pos, node)
|
|
|
|
|
2016-01-21 17:59:28 +03:00
|
|
|
local under = minetest.get_node({
|
|
|
|
x = pos.x,
|
|
|
|
y = pos.y - 1,
|
|
|
|
z = pos.z
|
|
|
|
}).name
|
2015-07-24 13:11:22 +03:00
|
|
|
|
2016-07-14 15:12:44 +03:00
|
|
|
if not minetest.registered_nodes[node.name] then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local height = minetest.registered_nodes[node.name].grown_height
|
|
|
|
|
2016-07-14 15:40:49 +03:00
|
|
|
-- do we have enough height to grow sapling into tree?
|
|
|
|
if not height or not enough_height(pos, height) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2016-05-17 23:40:05 +03:00
|
|
|
-- Check if Ethereal Sapling is growing on correct substrate
|
2015-07-25 18:45:29 +03:00
|
|
|
if node.name == "ethereal:yellow_tree_sapling"
|
2017-06-17 23:20:05 +03:00
|
|
|
-- and under == "default:dirt_with_snow" then
|
|
|
|
and minetest.get_item_group(under, "soil") > 0 then
|
2016-05-17 23:40:05 +03:00
|
|
|
ethereal.grow_yellow_tree(pos)
|
2015-07-25 18:45:29 +03:00
|
|
|
|
|
|
|
elseif node.name == "ethereal:big_tree_sapling"
|
2017-01-12 17:36:52 +03:00
|
|
|
--and under == "ethereal:green_dirt" then
|
|
|
|
and under == "default:dirt_with_grass" then
|
2016-05-17 23:40:05 +03:00
|
|
|
ethereal.grow_big_tree(pos)
|
2015-07-25 18:45:29 +03:00
|
|
|
|
|
|
|
elseif node.name == "ethereal:banana_tree_sapling"
|
2016-07-14 15:40:49 +03:00
|
|
|
and under == "ethereal:grove_dirt" then
|
2016-05-17 23:40:05 +03:00
|
|
|
ethereal.grow_banana_tree(pos)
|
2015-07-25 18:45:29 +03:00
|
|
|
|
|
|
|
elseif node.name == "ethereal:frost_tree_sapling"
|
2016-07-14 15:40:49 +03:00
|
|
|
and under == "ethereal:crystal_dirt" then
|
2016-05-17 23:40:05 +03:00
|
|
|
ethereal.grow_frost_tree(pos)
|
2015-07-25 18:45:29 +03:00
|
|
|
|
|
|
|
elseif node.name == "ethereal:mushroom_sapling"
|
2016-07-14 15:40:49 +03:00
|
|
|
and under == "ethereal:mushroom_dirt" then
|
2016-05-17 23:40:05 +03:00
|
|
|
ethereal.grow_mushroom_tree(pos)
|
2015-07-25 18:45:29 +03:00
|
|
|
|
|
|
|
elseif node.name == "ethereal:palm_sapling"
|
2016-07-14 15:40:49 +03:00
|
|
|
and under == "default:sand" then
|
2016-05-17 23:40:05 +03:00
|
|
|
ethereal.grow_palm_tree(pos)
|
2015-07-25 18:45:29 +03:00
|
|
|
|
|
|
|
elseif node.name == "ethereal:willow_sapling"
|
2016-07-14 15:40:49 +03:00
|
|
|
and under == "ethereal:gray_dirt" then
|
2016-05-17 23:40:05 +03:00
|
|
|
ethereal.grow_willow_tree(pos)
|
2015-07-25 18:45:29 +03:00
|
|
|
|
|
|
|
elseif node.name == "ethereal:redwood_sapling"
|
2017-01-12 15:05:53 +03:00
|
|
|
--and under == "bakedclay:red" then
|
|
|
|
and under == "default:dirt_with_dry_grass" then
|
2016-05-17 23:40:05 +03:00
|
|
|
ethereal.grow_redwood_tree(pos)
|
2015-07-25 18:45:29 +03:00
|
|
|
|
|
|
|
elseif node.name == "ethereal:orange_tree_sapling"
|
2016-07-14 15:40:49 +03:00
|
|
|
and under == "ethereal:prairie_dirt" then
|
2016-05-17 23:40:05 +03:00
|
|
|
ethereal.grow_orange_tree(pos)
|
2015-08-31 19:40:29 +03:00
|
|
|
|
|
|
|
elseif node.name == "ethereal:bamboo_sprout"
|
2016-07-14 15:40:49 +03:00
|
|
|
and under == "ethereal:bamboo_dirt" then
|
2016-05-17 23:40:05 +03:00
|
|
|
ethereal.grow_bamboo_tree(pos)
|
2015-11-14 13:21:06 +03:00
|
|
|
|
|
|
|
elseif node.name == "ethereal:birch_sapling"
|
2017-01-12 17:36:52 +03:00
|
|
|
--and under == "ethereal:green_dirt" then
|
|
|
|
and under == "default:dirt_with_grass" then
|
2016-05-17 23:40:05 +03:00
|
|
|
ethereal.grow_birch_tree(pos)
|
2015-07-24 13:11:22 +03:00
|
|
|
end
|
2016-05-17 23:40:05 +03:00
|
|
|
|
2015-07-24 13:11:22 +03:00
|
|
|
end
|
|
|
|
|
2014-11-09 22:17:41 +03:00
|
|
|
-- Grow saplings
|
|
|
|
minetest.register_abm({
|
2016-08-19 19:22:09 +03:00
|
|
|
label = "Ethereal grow sapling",
|
2014-11-09 22:17:41 +03:00
|
|
|
nodenames = {"group:ethereal_sapling"},
|
2017-06-17 23:34:36 +03:00
|
|
|
interval = 10,
|
|
|
|
chance = 50,
|
2015-11-07 23:50:50 +03:00
|
|
|
catch_up = false,
|
2014-11-09 22:17:41 +03:00
|
|
|
action = function(pos, node)
|
2015-10-01 21:01:07 +03:00
|
|
|
|
2016-05-17 23:40:05 +03:00
|
|
|
local light_level = minetest.get_node_light(pos)
|
2016-01-21 17:59:28 +03:00
|
|
|
|
2016-05-17 23:40:05 +03:00
|
|
|
if not light_level or light_level < 13 then
|
2015-10-01 21:01:07 +03:00
|
|
|
return
|
|
|
|
end
|
2016-01-21 17:59:28 +03:00
|
|
|
|
2016-05-17 23:40:05 +03:00
|
|
|
ethereal.grow_sapling(pos, node)
|
2015-10-01 21:01:07 +03:00
|
|
|
end,
|
|
|
|
})
|
2016-12-22 00:23:13 +03:00
|
|
|
|
2017-01-08 12:56:09 +03:00
|
|
|
--[[ burn saplings
|
2016-12-22 00:23:13 +03:00
|
|
|
minetest.register_craft({
|
|
|
|
type = "fuel",
|
|
|
|
recipe = "group:ethereal_sapling",
|
|
|
|
burntime = 10,
|
|
|
|
})
|
2017-01-08 12:56:09 +03:00
|
|
|
]]
|