Take replacements into consideration in Quick Crafting (fix #73)

This commit is contained in:
Jean-Patrick Guerrero 2022-08-14 20:29:22 +02:00
parent 0e2f233234
commit 0a8ae9a3d7

View File

@ -408,6 +408,7 @@ end
local function craft_stack(player, data, craft_rcp)
local inv = player:get_inventory()
local rcp_usg = craft_rcp and "recipe" or "usage"
local rcp_def = rcp_usg == "recipe" and data.recipes[data.rnum] or data.usages[data.unum]
local output = craft_rcp and data.recipes[data.rnum].output or data.usages[data.unum].output
output = ItemStack(output)
local stackname, stackcount, stackmax = output:get_name(), output:get_count(), output:get_stack_max()
@ -441,6 +442,14 @@ local function craft_stack(player, data, craft_rcp)
end
end
if rcp_def.replacements then
for _, v in ipairs(rcp_def.replacements) do
for _, item2 in ipairs(v) do
get_stack(player, ItemStack(item2))
end
end
end
local count = stackcount * scrbar_val
local iter = ceil(count / stackmax)
local leftover = count