From ad165825bd07f17e7a0f67279bdb56663ad99d00 Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Tue, 2 Apr 2019 16:45:11 -0400 Subject: [PATCH] milo use parallel during crafting for ingredients (holy shit thats fast) --- milo/apis/craft2.lua | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/milo/apis/craft2.lua b/milo/apis/craft2.lua index b0ab8f1..765b4e9 100644 --- a/milo/apis/craft2.lua +++ b/milo/apis/craft2.lua @@ -131,15 +131,23 @@ local function turtleCraft(recipe, storage, request, count) return end + local failed + local fns = { } for k,v in pairs(recipe.ingredients) do local item = splitKey(v) - if storage:export(storage.turtleInventory, k, count, item) ~= count then - request.status = 'rescan needed ?' - request.statusCode = Craft.STATUS_ERROR + table.insert(fns, function() + if storage:export(storage.turtleInventory, k, count, item) ~= count then + request.status = 'rescan needed ?' + request.statusCode = Craft.STATUS_ERROR + failed = true + _debug('failed to export: ' .. item.name) + end + end) + end -_debug('failed to export: ' .. item.name) - return - end + parallel.waitForAll(table.unpack(fns)) + if failed then + return end turtle.select(1)