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:
23
init.lua
23
init.lua
@ -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")
|
||||
|
||||
|
Reference in New Issue
Block a user