Runs everything in parallel now that we have reservations.

This commit is contained in:
Mike Stump 2024-01-07 17:47:40 -08:00
parent 9971678820
commit d869c77536

@ -3,7 +3,11 @@ local me = microexpansion
local pipeworks_craft_time = 1 local pipeworks_craft_time = 1
function me.autocraft_next_start(net) function me.autocraft_next_start(net)
if net.pending then -- We use machine reservations to allow simultaneous crafting jobs
-- todo: implement a limiter or a power consumption or 'crafting
-- cpus' for realism.
local parallel = true
if not parallel and net.pending then
-- start subsequent autocrafting jobs sequentially. -- start subsequent autocrafting jobs sequentially.
-- We really only need zero/not zero for build to queue actions or not -- We really only need zero/not zero for build to queue actions or not
return net.pending.time[net.pending.max_index] return net.pending.time[net.pending.max_index]
@ -87,11 +91,11 @@ local function build(net, cpos, inv, name, count, stack, sink, time)
max = math.min(max, count) max = math.min(max, count)
substack:set_count(max) substack:set_count(max)
local step_time local step_time
built, step_time = build(net, cpos, inv, name, max, substack, sink, next_time) built, step_time = build(net, cpos, inv, name, max, substack, sink, time)
if not built then if not built then
-- we are done, can't craft, so stop -- we are done, can't craft, so stop
else else
next_time = math.max(next_time, next_time + step_time) next_time = math.max(next_time, time + step_time)
end end
count = count - max count = count - max
end end