Thanks! It is I searched for! Now I have 2 additional grouping filter in smart_inventory ;-)
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
filter.register_filter({
name = "eatable",
filter_func = function(def, name)
if def.on_use then
local name,change=debug.getupvalue(def.on_use, 1)
if name~=nil and name=="hp_change" and change > 0 then
return tostring(change)
end
end
end
})
filter.register_filter({
name = "toxic",
filter_func = function(def, name)
if def.on_use then
local name,change=debug.getupvalue(def.on_use, 1)
if name~=nil and name=="hp_change" and change < 0 then
return tostring(change)
end
end
end
})
A hint for you: you do not need to read minetest.registered_nodes, minetest.registered_craftitems, minetest.registered_tools. All items are in the registered_items table, with type="node","tool" or "craft" ;-)
So you can reduce your code to
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 ob = minetest.registered_items[name]
if ob and ob.on_use then
local name,change=debug.getupvalue(ob.on_use, 1)
if name~=nil and name=="hp_change" then
return change
end
end
return nil
end