Skip to content

Commit

Permalink
Add grinder bugfix from Micu
Browse files Browse the repository at this point in the history
  • Loading branch information
joe7575 committed Jun 14, 2021
1 parent 288472d commit 60487a2
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions basic_machines/grinder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,24 +99,29 @@ local function src_to_dst(src_stack, idx, src_name, num_items, inp_num, inv, dst
end

local function grinding(pos, crd, nvm, inv)
local num_items = 0
local blocked = false -- idle
for idx,stack in ipairs(inv:get_list("src")) do
if not stack:is_empty() then
local name = stack:get_name()
if Recipes[name] then
local recipe = Recipes[name]
if src_to_dst(stack, idx, name, crd.num_items, recipe.inp_num, inv, recipe.output) then
crd.State:keep_running(pos, nvm, COUNTDOWN_TICKS)
return
else
crd.State:blocked(pos, nvm)
blocked = true
end
else
crd.State:fault(pos, nvm)
return
end
return
end
end
crd.State:idle(pos, nvm)
if blocked then
crd.State:blocked(pos, nvm)
else
crd.State:idle(pos, nvm)
end
end

local function keep_running(pos, elapsed)
Expand Down

0 comments on commit 60487a2

Please sign in to comment.