1
0
mirror of https://codeberg.org/tenplus1/farming.git synced 2025-06-28 22:36:45 +02:00

add helper function to add {eatable}

This commit is contained in:
tenplus1
2024-07-26 16:30:53 +01:00
parent 648bae7517
commit 75e3f9fb42
41 changed files with 387 additions and 205 deletions

View File

@ -7,7 +7,7 @@
farming = {
mod = "redo",
version = "20240625",
version = "20240726",
path = minetest.get_modpath("farming"),
select = {
type = "fixed",
@ -767,6 +767,27 @@ if input then
input:close()
end
-- helper function to add {eatable} group to food items
local mod_tt_base = minetest.get_modpath("tt_base") -- mod does similar to infotext
function farming.add_eatable(item, hp)
local def = minetest.registered_items[item]
if def then
local grps = def.groups or {}
grps.eatable = hp ; grps.flammable = 2
if mod_tt_base == nil then
def.description = def.description .. " (♥" .. hp .. ")"
end
minetest.override_item(item, {description = def.description, groups = grps})
end
end
-- recipe items
dofile(farming.path .. "/items.lua")