[TIP] Check if items are eatable
Because its useful, and there have been questions about this before.
the function will return number of the hp change or nil.
the function will return number of the hp change or nil.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
eatable=function(name)
local def={
minetest.registered_items[name],
minetest.registered_nodes[name],
minetest.registered_craftitems[name],
minetest.registered_tools[name]
}
for _, ob in pairs(def) do
if ob~=nil then
local name,change=debug.getupvalue(ob.on_use, 1)
if name~=nil and name=="hp_change" then
return change
end
end
end
return nil
end