Fix group replacements in Quick Crafting

This commit is contained in:
Jean-Patrick Guerrero 2023-01-20 21:19:35 +01:00
parent b4482f0acf
commit b6b97aa284

View File

@ -444,12 +444,22 @@ local function craft_stack(player, data, craft_rcp)
for _ = 1, v * scrbar_val do
inv:remove_item("main", item)
if rcp_def.replacements then
for _, pair in ipairs(rcp_def.replacements) do
if item == pair[1] then
get_stack(player, ItemStack(pair[2]))
for _, pair in ipairs(rcp_def.replacements or {}) do
local old_name, new_name = unpack(pair)
if is_group(old_name) then
local groups = extract_groups(old_name)
local groupname = old_name:sub(7)
local item_groups = i3.groups[groupname].items or groups_to_items(groups)
for _, it in ipairs(item_groups) do
if item == it then
get_stack(player, ItemStack(new_name))
end
end
elseif item == old_name then
get_stack(player, ItemStack(new_name))
end
end
end
end