update {eatable} function
This commit is contained in:
parent
04285b8bff
commit
7b0071b81a
11
init.lua
11
init.lua
@ -819,21 +819,24 @@ minetest.register_abm({
|
|||||||
--
|
--
|
||||||
|
|
||||||
local mod_tt_base = minetest.get_modpath("tt_base")
|
local mod_tt_base = minetest.get_modpath("tt_base")
|
||||||
|
|
||||||
local function add_eatable(item, hp)
|
local function add_eatable(item, hp)
|
||||||
|
|
||||||
local def = minetest.registered_items[item]
|
local def = minetest.registered_items[item]
|
||||||
|
|
||||||
if def then
|
if def then
|
||||||
|
|
||||||
local grps = def.groups or {}
|
local groups = table.copy(def.groups) or {}
|
||||||
|
local txt = " (" ; if hp > 0 then txt = txt .. "+" end
|
||||||
|
txt = txt .. hp .. " HP)"
|
||||||
|
|
||||||
grps.eatable = hp ; grps.flammable = 2
|
groups.eatable = hp ; groups.flammable = 2
|
||||||
|
|
||||||
if mod_tt_base == nil then
|
if mod_tt_base == nil then
|
||||||
def.description = def.description .. " (+" .. hp .. " HP)"
|
def.description = def.description .. txt
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.override_item(item, {description = def.description, groups = grps})
|
minetest.override_item(item, {description = def.description, groups = groups})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user