From dc93bb5f165a080fbf9d3d3372dfba3aaa2af285 Mon Sep 17 00:00:00 2001 From: Louis Royer <4259825-lroyer@users.noreply.gitlab.com> Date: Tue, 25 Aug 2020 19:31:39 +0200 Subject: [PATCH] Add coconut milk craft using cutting board from farming redo - Add coconut milk to group vessel - Give an empty vessel back to player after eating coconut milk --- crafts.lua | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/crafts.lua b/crafts.lua index f383b6f..3f467e1 100644 --- a/crafts.lua +++ b/crafts.lua @@ -38,7 +38,8 @@ minetest.register_craftitem("moretrees:coconut_milk", { description = S("Coconut Milk"), inventory_image = "moretrees_coconut_milk_inv.png", wield_image = "moretrees_coconut_milk.png", - on_use = minetest.item_eat(2), + on_use = minetest.item_eat(2, "vessels:drinking_glass"), + groups = {vessel = 1}, }) minetest.register_craftitem("moretrees:raw_coconut", { @@ -120,6 +121,7 @@ for i in ipairs(moretrees.cutting_tools) do } }) end + -- give tool back with wear preserved minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv) if (itemstack:get_name() == "moretrees:coconut_milk") then @@ -127,6 +129,10 @@ minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv -- find tool used to do the craft local ocg_name = j:get_name() if ((ocg_name ~= "") and (ocg_name ~= "moretrees:coconut") and (ocg_name ~= "vessels:drinking_glass")) then + -- abort if using cutting board + if minetest.get_item_group(ocg_name, "food_cutting_board") == 1 then + return + end -- create a new tool and set wear local t = ItemStack(ocg_name) local w = j:get_wear() @@ -148,9 +154,27 @@ minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv craft_inv:add_item("craft", t) end end - end + end end) +-- coconut milk using food_cutting_board from farming redo +if minetest.registered_items["farming:cutting_board"] then + minetest.register_craft({ + type = "shapeless", + output = "moretrees:coconut_milk", + recipe = { + "moretrees:coconut", + "vessels:drinking_glass", + "group:food_cutting_board", + }, + replacements = { + { "moretrees:coconut", "moretrees:raw_coconut" }, + { "group:food_cutting_board", "farming:cutting_board" }, + } + }) +end + + minetest.register_craft({ type = "shapeless", output = "moretrees:date_nut_snack",