add food registration utility to mcl_vegan_utils.

This commit is contained in:
trans_soup 2023-07-17 13:04:04 +02:00
parent 936ca6f558
commit b12dfcfbcc
2 changed files with 27 additions and 0 deletions

26
mcl_vegan_utils/food.lua Normal file
View File

@ -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

View File

@ -12,3 +12,4 @@ include("debug")
include("farming_node")
include("farming_item")
include("drops")
include("food")