From 9eb8e75efb20aaeffa935d53225b4495df657337 Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Mon, 20 May 2024 09:40:38 +0200 Subject: [PATCH] Fix bug with injector and a full 8x2000 chest --- basic_machines/ta4_injector.lua | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/basic_machines/ta4_injector.lua b/basic_machines/ta4_injector.lua index 0689461..b184e54 100644 --- a/basic_machines/ta4_injector.lua +++ b/basic_machines/ta4_injector.lua @@ -122,8 +122,23 @@ local function push_items(pos, out_dir, idx, items) return true end end + return false else - return techage.push_items(pos, out_dir, items, idx) + local taken = items:get_count() + local leftover = techage.push_items(pos, out_dir, items, idx) + if leftover == false then + return false -- No items placed + elseif leftover ~= true then + -- One or more items placed? + if leftover:get_count() < taken then + -- place the rest back + local pull_dir = M(pos):get_int("pull_dir") + techage.unpull_items(pos, pull_dir, leftover) + return true -- Some items placed + end + return false -- No items placed + end + return true -- All items placed end end