diff options
author | Ciaran Gultnieks <ciaran@ciarang.com> | 2014-04-14 19:01:29 +0100 |
---|---|---|
committer | Ciaran Gultnieks <ciaran@ciarang.com> | 2014-04-14 19:06:17 +0100 |
commit | 3a335e9de2e7874f0f6ba87bf0555a7be74c1d15 (patch) | |
tree | af51f1ac03905576499eeaa07f2720c7aef2dd54 | |
parent | 9de90d2766c49b00286d4be4c3bc83e820f454e5 (diff) |
A couple of fixes to item overriding
This resolves several problems, including the one repeatedly reported
in the mod's forum topic about "insane recipes".
-rw-r--r-- | init.lua | 21 |
1 files changed, 8 insertions, 13 deletions
@@ -36,26 +36,21 @@ function food.support(group,mod,item) return end - local mtype = "item" - - if minetest.registered_nodes[item] then - mtype = "node" - end - local data = minetest.registered_items[item] - if not data then print("[FOOD MOD WARNING] item '"..item.."' not found") return end - data.groups["food_"..group]=1 - - if mtype == "item" then - minetest.register_craftitem(":"..item,data) - else - minetest.register_node(":"..item,data) + -- Need to copy this table, not modify it in place, otherwise it can change + -- the groups for ALL craftitems that use the default groups. + g = {} + for k, v in pairs(data.groups) do + g[k] = v end + g["food_"..group] = 1 + minetest.override_item(item, {groups = g}) + food.supported[group] = true end |