From 5a96e4a09de56ec277fc0c653443833e1f520974 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 21 Jul 2023 17:25:30 +0200 Subject: [PATCH] Workbench cut: Reduce waste if reaching stack_max --- src/workbench.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/workbench.lua b/src/workbench.lua index dc7c57e..276619d 100644 --- a/src/workbench.lua +++ b/src/workbench.lua @@ -81,7 +81,12 @@ function workbench:get_output(inv, input, name) for i = 1, #self.defs do local nbox = self.defs[i] local cuttype = nbox[1] - local count = min(nbox[2] * input:get_count(), input:get_stack_max()) + local count = nbox[2] * input:get_count() + local max_count = input:get_stack_max() + if count > max_count then + -- Limit count to maximum multiple to avoid waste + count = nbox[2] * math.floor(max_count / nbox[2]) + end local was_cut = false if extended or nbox[3] == nil then local item = name .. "_" .. cuttype