mirror of
https://github.com/joe7575/techpack.git
synced 2024-11-29 18:43:53 +01:00
fermenter: improve input items processing.
Change source item pulling logic: previously 2 leaves items were taken at once from the same stack, so only identical types were used to produce Biogas (remaining single items could fill up source tray). Now items are taken one by one, allowing 2 different plant leaves to form 1 Biogas unit. That cleans up inventory as well - maximum one item is left there when production ends. Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
This commit is contained in:
parent
d0ff85fc41
commit
f2d12c9aaa
@ -91,17 +91,31 @@ local function convert_leaves_to_biogas(meta)
|
|||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
local biogas = ItemStack("tubelib_addons1:biogas")
|
local biogas = ItemStack("tubelib_addons1:biogas")
|
||||||
if inv:room_for_item("dst", biogas) then -- enough output space?
|
if inv:room_for_item("dst", biogas) then -- enough output space?
|
||||||
local items = tubelib.get_num_items(meta, "src", 2)
|
local items = {}
|
||||||
if items then -- input available?
|
local fault = false
|
||||||
if is_leaves(items:get_name()) then
|
for i = 1, 2 do
|
||||||
inv:add_item("dst", biogas)
|
items[i] = tubelib.get_num_items(meta, "src", 1)
|
||||||
return true
|
if items[i] then -- input available?
|
||||||
|
if not is_leaves(items[i]:get_name()) then
|
||||||
|
fault = true
|
||||||
|
break
|
||||||
|
end
|
||||||
else
|
else
|
||||||
inv:add_item("src", items)
|
break
|
||||||
return nil -- error
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
if #items == 2 then
|
||||||
|
inv:add_item("dst", biogas)
|
||||||
|
return true
|
||||||
else
|
else
|
||||||
return false -- standby
|
for i = 1, #items do
|
||||||
|
inv:add_item("src", items[i])
|
||||||
|
end
|
||||||
|
if fault then
|
||||||
|
return nil -- error
|
||||||
|
else
|
||||||
|
return false -- standby
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
return false -- standby
|
return false -- standby
|
||||||
|
Loading…
Reference in New Issue
Block a user