mirror of
https://github.com/mt-mods/pipeworks.git
synced 2025-05-11 21:30:22 +02:00
reorder and change back var name
This commit is contained in:
parent
df79b74f2f
commit
2f70be2d90
@ -101,16 +101,6 @@ end
|
|||||||
|
|
||||||
local function autocraft(inventory, craft)
|
local function autocraft(inventory, craft)
|
||||||
if not craft then return false end
|
if not craft then return false end
|
||||||
-- check if we have enough material available
|
|
||||||
local inv_index = count_index(inventory:get_list("src"))
|
|
||||||
local consumption = calculate_consumption(inv_index, craft.consumption)
|
|
||||||
if not consumption then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
-- check if we have enough material available
|
|
||||||
for itemname, number in pairs(consumption) do
|
|
||||||
if (not inv_index[itemname]) or inv_index[itemname] < number then return false end
|
|
||||||
end
|
|
||||||
-- check if output and all replacements fit in dst
|
-- check if output and all replacements fit in dst
|
||||||
local output = craft.output.item
|
local output = craft.output.item
|
||||||
local out_items = count_index(craft.decremented_input.items)
|
local out_items = count_index(craft.decremented_input.items)
|
||||||
@ -134,8 +124,17 @@ local function autocraft(inventory, craft)
|
|||||||
if empty_count < 0 then
|
if empty_count < 0 then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
-- check if we have enough material available
|
||||||
|
local inv_index = count_index(inventory:get_list("src"))
|
||||||
|
local consumption = calculate_consumption(inv_index, craft.consumption)
|
||||||
|
if not consumption then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
for itemname, number in pairs(consumption) do
|
||||||
|
if (not inv_index[itemname]) or inv_index[itemname] < number then return false end
|
||||||
|
end
|
||||||
-- consume material
|
-- consume material
|
||||||
for itemname, number in pairs(craft.consumption) do
|
for itemname, number in pairs(consumption) do
|
||||||
for _ = 1, number do -- We have to do that since remove_item does not work if count > stack_max
|
for _ = 1, number do -- We have to do that since remove_item does not work if count > stack_max
|
||||||
inventory:remove_item("src", ItemStack(itemname))
|
inventory:remove_item("src", ItemStack(itemname))
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user