diff options
author | JP Guerrero <jeanpatrick.guerrero@gmail.com> | 2016-12-11 16:01:51 +0100 |
---|---|---|
committer | JP Guerrero <jeanpatrick.guerrero@gmail.com> | 2016-12-11 16:08:07 +0100 |
commit | 9c8ae2b69a865507faf649c202b6b793e78c06e3 (patch) | |
tree | e60c85acf0ae0ddba2b8d14019c00e7104662f8b /init.lua | |
parent | aa4f2c55f23a3a19190e9c7587cd3a54745766de (diff) |
Progressive Mode: Fix item groups not being fully considered
Diffstat (limited to 'init.lua')
-rw-r--r-- | init.lua | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -168,6 +168,14 @@ local function has_item(T) for i=1, #T do if T[i] then return true end end end +local function group_to_items(group) + local T = {} + for name, def in pairs(minetest.registered_items) do + if def.groups[group:sub(7)] then T[#T+1] = name end + end + return T +end + function craftguide:recipe_in_inv(player_name, item_name) local player = minetest.get_player_by_name(player_name) local inv = player:get_inventory() @@ -177,7 +185,17 @@ function craftguide:recipe_in_inv(player_name, item_name) for i=1, #recipes do T[i] = true for _, item in pairs(recipes[i].items) do - if not inv:contains_item("main", self:group_to_item(item)) then + local group_in_inv = false + if item:sub(1,6) == "group:" then + local groups = group_to_items(item) + for j=1, #groups do + if inv:contains_item("main", groups[j]) then + group_in_inv = true + end + end + end + + if not group_in_inv and not inv:contains_item("main", item) then T[i] = false end end |