diff --git a/mods/bg_tree/grow.lua b/mods/bg_tree/grow.lua index 010376b..43b1cd2 100644 --- a/mods/bg_tree/grow.lua +++ b/mods/bg_tree/grow.lua @@ -2,6 +2,16 @@ local modname = minetest.get_current_modname() local api = blockgame.tree local vec = blockgame.vector +-- NODE NAMES + +local log = modname .. ":log" +local log_alive = modname .. ":log_alive" +local leaves = modname .. ":leaves" +local leaves_alive = modname .. ":leaves_alive" +local root = modname .. ":root" + +-- END OF NODE NAMES + local attempt_place = function (pos, node) if minetest.get_node(pos).name ~= "air" then return false end return minetest.set_node(pos, node) @@ -10,7 +20,7 @@ end local extend_leaves_from = function (pos) local side = vec.random_side() - attempt_place(pos + side, {name = modname .. ":leaves"}) + attempt_place(pos + side, {name = leaves_alive}) end local random_walk = function (pos, steps, check) @@ -27,15 +37,15 @@ end local spread_roots_from = function (source) local root_pos = random_walk(source, 2, function (pos) - if minetest.get_node(pos).name == modname .. ":log" then return true end - if minetest.get_node(pos).name == modname .. ":root" then return true end + if minetest.get_node(pos).name == log_alive then return true end + if minetest.get_node(pos).name == root then return true end return false end) local root_node = minetest.get_node(root_pos) - if minetest.get_node(root_pos + vector.new(0, 1, 0)).name == modname .. ":log" then - minetest.set_node(root_pos, {name = modname .. ":root"}) + if minetest.get_node(root_pos + vector.new(0, 1, 0)).name == log_alive then + minetest.set_node(root_pos, {name = root}) return true end @@ -44,7 +54,7 @@ local spread_roots_from = function (source) if blockgame.chance(2) then target_pos = vec.get_below(root_pos) end if minetest.get_item_group(minetest.get_node(target_pos), "dirty") then - return minetest.set_node(target_pos, {name = modname .. ":root"}) + return minetest.set_node(target_pos, {name = root}) end return false @@ -53,7 +63,7 @@ end minetest.register_abm({ label = "sapling grow", nodenames = {"tree:sapling"}, - neighbors = {"group:dirty", modname .. ":log"}, + neighbors = {"group:dirty", log_alive}, interval = 15, chance = 4, catch_up = true, @@ -78,7 +88,7 @@ minetest.register_abm({ local side = vec.random_side() local target = pos + side - attempt_place(target, {name = modname .. ":log"}) + attempt_place(target, {name = log_alive}) if blockgame.chance(2) then extend_leaves_from(target) @@ -86,9 +96,9 @@ minetest.register_abm({ end if blockgame.chance(4) then - minetest.set_node(pos, {name = modname .. ":log"}) + minetest.set_node(pos, {name = log_alive}) - if minetest.get_node(below).name == modname .. ":log" and blockgame.chance(2) then return end + if minetest.get_node(below).name == log_alive and blockgame.chance(2) then return end attempt_place(pos + vector.new(0, 1, 0), {name = modname .. ":sapling"}) end diff --git a/mods/bg_tree/node.lua b/mods/bg_tree/node.lua index ea4ae3a..65fcade 100644 --- a/mods/bg_tree/node.lua +++ b/mods/bg_tree/node.lua @@ -3,11 +3,24 @@ local modname = minetest.get_current_modname() blockgame.reg_simple_node("log", "Log", { woody = 1, }) +minetest.register_node(modname .. ":log_alive", { + description = "Growing Log", + tiles = { + modname .. "_log_top.png", + modname .. "_log_alive.png", + }, + groups = { + woody = 1, + planty = 1, + }, + drop = modname .. ":log", +}) blockgame.reg_simple_node("sapling", "Sapling", { planty = 1, }) +-- TODO: move this to the woodworking mod. blockgame.reg_simple_node("plank", "Plank", { woody = 1, }) @@ -23,23 +36,19 @@ minetest.register_node(modname .. ":leaves", { groups = { planty = 1, }, - drop = { - max_items = 2, - items = { - { - rarity = 16, - items = {modname .. ":nut 3"} - }, - { - rarity = 8, - items = {modname .. ":nut 2"} - }, - { - rarity = 4, - items = {modname .. ":nut"} - }, - }, +}) +minetest.register_node(modname .. ":leaves_alive", { + description = "Growing Leaves", + drawtype = "glasslike", + tiles = { + modname .. "_leaves_alive.png", }, + paramtype = "light", + sunlight_propagates = true, + groups = { + planty = 1, + }, + drop = modname .. ":leaves", }) blockgame.reg_simple_node("nut", "Nut", { diff --git a/mods/bg_tree/recipes.lua b/mods/bg_tree/recipes.lua index 0f5754e..54da2a4 100644 --- a/mods/bg_tree/recipes.lua +++ b/mods/bg_tree/recipes.lua @@ -5,7 +5,6 @@ local modname = minetest.get_current_modname() blockgame.crafting.register_stack_recipe("core:grass", modname .. ":nut", {name = modname .. ":sapling"}) blockgame.crafting.register_stack_recipe("core:dirt", modname .. ":nut", {name = modname .. ":sapling"}) --- NOTE: is currently useless, as there's no way to obtain leaves. blockgame.crafting.register_pummel_recipe({ label = "pummel leaves into dirt", used_item = modname .. ":leaves", @@ -15,6 +14,7 @@ blockgame.crafting.register_pummel_recipe({ end, }) +-- TODO: move this to the woodworking mod. blockgame.crafting.register_pummel_recipe({ label = "pummel log into plank", used_item = "core:stone", diff --git a/mods/bg_tree/textures/tree_leaves.png b/mods/bg_tree/textures/tree_leaves.png index e28ac8f..4438ea9 100644 Binary files a/mods/bg_tree/textures/tree_leaves.png and b/mods/bg_tree/textures/tree_leaves.png differ diff --git a/mods/bg_tree/textures/tree_leaves_alive.png b/mods/bg_tree/textures/tree_leaves_alive.png new file mode 100644 index 0000000..96401cc Binary files /dev/null and b/mods/bg_tree/textures/tree_leaves_alive.png differ diff --git a/mods/bg_tree/textures/tree_log.png b/mods/bg_tree/textures/tree_log.png index fe89963..4891e5b 100644 Binary files a/mods/bg_tree/textures/tree_log.png and b/mods/bg_tree/textures/tree_log.png differ diff --git a/mods/bg_tree/textures/tree_log_alive.png b/mods/bg_tree/textures/tree_log_alive.png new file mode 100644 index 0000000..2f2a927 Binary files /dev/null and b/mods/bg_tree/textures/tree_log_alive.png differ diff --git a/mods/bg_tree/textures/tree_log_top.png b/mods/bg_tree/textures/tree_log_top.png index 9205ed9..2efd635 100644 Binary files a/mods/bg_tree/textures/tree_log_top.png and b/mods/bg_tree/textures/tree_log_top.png differ diff --git a/mods/bg_tree/textures/tree_log_top_alive.png b/mods/bg_tree/textures/tree_log_top_alive.png new file mode 100644 index 0000000..0cdcaf9 Binary files /dev/null and b/mods/bg_tree/textures/tree_log_top_alive.png differ