biogasmachines: gasifier: fixed working tray item processing.

Fixed incorrect behaviour when machine was restarted with non-empty
working tray. Now device checks this tray before source (input) inventory
and if item is present, sets it for processing.

Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
This commit is contained in:
Michal Cieslakiewicz 2018-11-19 13:37:04 +01:00
parent 22ef12415d
commit 33c7cbf09e

View File

@ -416,6 +416,16 @@ local function on_timer(pos, elapsed)
end
-- choose item
local inputname = nil
if not inv:is_empty("cur") then
-- leftover item, start from beginning
local inp = inv:get_stack("cur", 1)
inputname = inp:get_name()
if not biogas_recipes[inputname] then
return gasifier_fault(pos) -- oops
end
prodtime = biogas_recipes[inputname].time
else
-- prepare item, next tick will start processing
for i, r in pairs(biogas_recipes) do
if inv:contains_item("src", ItemStack(i .. " 1")) and
inv:room_for_item("dst",
@ -431,12 +441,12 @@ local function on_timer(pos, elapsed)
if not inputname then
return true
end
-- move item to working tray, next tick will start processing
local inp = inv:remove_item("src", ItemStack(inputname .. " 1"))
if inp:is_empty() then
return gasifier_fault(pos) -- oops
end
inv:add_item("cur", inp)
end
meta:set_string("item_name", inputname)
itemcnt = prodtime
else