Fix Quick Crafting bugs
This commit is contained in:
parent
187b0339bd
commit
889259ac5e
|
@ -178,7 +178,7 @@ local function cache_recipes(item)
|
|||
_recipes[#recipes + 1 - k] = v
|
||||
end
|
||||
|
||||
local shift = 0
|
||||
local shift = 1
|
||||
local size_rpl = maxn(replacements[item])
|
||||
local size_rcp = #_recipes
|
||||
|
||||
|
|
|
@ -428,26 +428,30 @@ local function craft_stack(player, data, craft_rcp)
|
|||
local remaining = count
|
||||
|
||||
for _, item in ipairs(item_groups) do
|
||||
for _name, _count in pairs(data.crafting_counts[rcp_usg].inv) do
|
||||
if item == _name and remaining > 0 then
|
||||
local c = min(remaining, _count)
|
||||
items[item] = c
|
||||
remaining -= c
|
||||
for _name, _count in pairs(data.crafting_counts[rcp_usg].inv) do
|
||||
if item == _name and remaining > 0 then
|
||||
local c = min(remaining, _count)
|
||||
items[item] = c
|
||||
remaining -= c
|
||||
end
|
||||
|
||||
if remaining == 0 then break end
|
||||
end
|
||||
|
||||
if remaining == 0 then break end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for k, v in pairs(items) do
|
||||
inv:remove_item("main", fmt("%s %s", k, v * scrbar_val))
|
||||
end
|
||||
end
|
||||
for item, v in pairs(items) do
|
||||
for _ = 1, v * scrbar_val do
|
||||
inv:remove_item("main", item)
|
||||
|
||||
if rcp_def.replacements then
|
||||
for _, pair in ipairs(rcp_def.replacements) do
|
||||
get_stack(player, ItemStack(pair[2]))
|
||||
if rcp_def.replacements then
|
||||
for _, pair in ipairs(rcp_def.replacements) do
|
||||
if item == pair[1] then
|
||||
get_stack(player, ItemStack(pair[2]))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1044,11 +1044,9 @@ local function get_grid_fs(fs, data, rcp, is_recipe, is_usage)
|
|||
local label = groups and "\nG" or ""
|
||||
local replace
|
||||
|
||||
for j = 1, #(rcp.replacements or {}) do
|
||||
local replacement = rcp.replacements[j]
|
||||
for _, replacement in ipairs(rcp.replacements or {}) do
|
||||
if replacement[1] == name then
|
||||
replace = replace or {type = rcp.type, items = {}}
|
||||
|
||||
local added
|
||||
|
||||
for _, v in ipairs(replace.items) do
|
||||
|
@ -1087,7 +1085,12 @@ local function get_grid_fs(fs, data, rcp, is_recipe, is_usage)
|
|||
item:set_name(name)
|
||||
item:set_count(count)
|
||||
local itemstr = ESC(item:to_string())
|
||||
|
||||
item_image_button(X, Y, btn_size, btn_size, itemstr, btn_name, label)
|
||||
|
||||
if item:get_stack_max() < count then
|
||||
label(X + 0.95, Y + 0.95, count)
|
||||
end
|
||||
end
|
||||
|
||||
local def = reg_items[name]
|
||||
|
|
Ŝarĝante…
Reference in New Issue