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
|
_recipes[#recipes + 1 - k] = v
|
||||||
end
|
end
|
||||||
|
|
||||||
local shift = 0
|
local shift = 1
|
||||||
local size_rpl = maxn(replacements[item])
|
local size_rpl = maxn(replacements[item])
|
||||||
local size_rcp = #_recipes
|
local size_rcp = #_recipes
|
||||||
|
|
||||||
|
|
|
@ -428,26 +428,30 @@ local function craft_stack(player, data, craft_rcp)
|
||||||
local remaining = count
|
local remaining = count
|
||||||
|
|
||||||
for _, item in ipairs(item_groups) do
|
for _, item in ipairs(item_groups) do
|
||||||
for _name, _count in pairs(data.crafting_counts[rcp_usg].inv) do
|
for _name, _count in pairs(data.crafting_counts[rcp_usg].inv) do
|
||||||
if item == _name and remaining > 0 then
|
if item == _name and remaining > 0 then
|
||||||
local c = min(remaining, _count)
|
local c = min(remaining, _count)
|
||||||
items[item] = c
|
items[item] = c
|
||||||
remaining -= c
|
remaining -= c
|
||||||
|
end
|
||||||
|
|
||||||
|
if remaining == 0 then break end
|
||||||
end
|
end
|
||||||
|
|
||||||
if remaining == 0 then break end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for k, v in pairs(items) do
|
for item, v in pairs(items) do
|
||||||
inv:remove_item("main", fmt("%s %s", k, v * scrbar_val))
|
for _ = 1, v * scrbar_val do
|
||||||
end
|
inv:remove_item("main", item)
|
||||||
end
|
|
||||||
|
|
||||||
if rcp_def.replacements then
|
if rcp_def.replacements then
|
||||||
for _, pair in ipairs(rcp_def.replacements) do
|
for _, pair in ipairs(rcp_def.replacements) do
|
||||||
get_stack(player, ItemStack(pair[2]))
|
if item == pair[1] then
|
||||||
|
get_stack(player, ItemStack(pair[2]))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
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 label = groups and "\nG" or ""
|
||||||
local replace
|
local replace
|
||||||
|
|
||||||
for j = 1, #(rcp.replacements or {}) do
|
for _, replacement in ipairs(rcp.replacements or {}) do
|
||||||
local replacement = rcp.replacements[j]
|
|
||||||
if replacement[1] == name then
|
if replacement[1] == name then
|
||||||
replace = replace or {type = rcp.type, items = {}}
|
replace = replace or {type = rcp.type, items = {}}
|
||||||
|
|
||||||
local added
|
local added
|
||||||
|
|
||||||
for _, v in ipairs(replace.items) do
|
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_name(name)
|
||||||
item:set_count(count)
|
item:set_count(count)
|
||||||
local itemstr = ESC(item:to_string())
|
local itemstr = ESC(item:to_string())
|
||||||
|
|
||||||
item_image_button(X, Y, btn_size, btn_size, itemstr, btn_name, label)
|
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
|
end
|
||||||
|
|
||||||
local def = reg_items[name]
|
local def = reg_items[name]
|
||||||
|
|
Ŝarĝante…
Reference in New Issue