From b12dfcfbcc10c7296d26d1216a1526ebd5e74ffb Mon Sep 17 00:00:00 2001 From: trans_soup <> Date: Mon, 17 Jul 2023 13:04:04 +0200 Subject: [PATCH] add food registration utility to mcl_vegan_utils. --- mcl_vegan_utils/food.lua | 26 ++++++++++++++++++++++++++ mcl_vegan_utils/init.lua | 1 + 2 files changed, 27 insertions(+) create mode 100644 mcl_vegan_utils/food.lua diff --git a/mcl_vegan_utils/food.lua b/mcl_vegan_utils/food.lua new file mode 100644 index 0000000..55f5f81 --- /dev/null +++ b/mcl_vegan_utils/food.lua @@ -0,0 +1,26 @@ +function mcl_vegan.register_food (own_mod_name, base_name, def) + def.own_mod_name = own_mod_name + def.base_name = base_name + + local full_base_name = own_mod_name .. ":" .. base_name + + def.description = def.description or base_name + local description = def.description + def.food_strength = def.food_strength or 1.0 + local food_strength = def.food_strength + def.saturation = def.saturation or 0.0 + local saturation = def.saturation + + minetest.register_craftitem(full_base_name, { + description = description, + inventory_image = own_mod_name .. "_" .. base_name .. ".png", + groups = { + craftitem = 1, + food = 1, + eatable = food_strength, + }, + _mcl_saturation = saturation, + on_place = minetest.item_eat(food_strength), + on_secondary_use = minetest.item_eat(food_strength), + }) +end diff --git a/mcl_vegan_utils/init.lua b/mcl_vegan_utils/init.lua index 6d7c952..0b4205d 100644 --- a/mcl_vegan_utils/init.lua +++ b/mcl_vegan_utils/init.lua @@ -12,3 +12,4 @@ include("debug") include("farming_node") include("farming_item") include("drops") +include("food")