diff --git a/mods/bg_tree/recipes.lua b/mods/bg_tree/recipes.lua index 8632130..0f5754e 100644 --- a/mods/bg_tree/recipes.lua +++ b/mods/bg_tree/recipes.lua @@ -1,4 +1,36 @@ local modname = minetest.get_current_modname() +-- plant saplings +-- TODO: when recipes add support for groups, use `dirty` group here instead of specific nodes. blockgame.crafting.register_stack_recipe("core:grass", modname .. ":nut", {name = modname .. ":sapling"}) -blockgame.crafting.register_stack_recipe(modname .. ":log", modname .. ":nut", {name = modname .. ":plank"}) +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", + target_node = modname .. ":leaves", + on_success = function (pos, used_node, target_node) + minetest.set_node(pos, {name = "core:dirt"}) + end, +}) + +blockgame.crafting.register_pummel_recipe({ + label = "pummel log into plank", + used_item = "core:stone", + target_node = modname .. ":log", + check = function (pos, used_node, target_node) + for _, side in pairs(blockgame.vector.sides) do + local output_pos = pos + side + if minetest.get_node(output_pos).name ~= "air" then return false end + end + return true + end, + on_success = function (pos, used_node, target_node) + minetest.remove_node(pos) + for _, side in pairs(blockgame.vector.sides) do + local output_pos = pos + side + minetest.set_node(output_pos, {name = modname .. ":plank"}) + end + end, +})