From 8590f867bd045c0b4dcc368f87c55ba9055c236b Mon Sep 17 00:00:00 2001 From: kepler155c Date: Mon, 26 Mar 2018 17:16:46 -0400 Subject: [PATCH] refined storage initial update - wip --- apis/meAdapter.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/apis/meAdapter.lua b/apis/meAdapter.lua index 35cb0a9..77ed989 100644 --- a/apis/meAdapter.lua +++ b/apis/meAdapter.lua @@ -202,6 +202,28 @@ function MEAdapter:isCrafting(item) end end +function MEAdapter:craftItems(items) + local cpus = self.getCraftingCPUs() or { } + local count = 0 + + for _,cpu in pairs(cpus) do + if cpu.busy then + return + end + end + + for _,item in pairs(items) do + if count >= #cpus then + break + end + if not self:isCrafting(item) then + if self:craft(item, item.count) then + count = count + 1 + end + end + end +end + function MEAdapter:provide(item, qty, slot, direction) return pcall(function() for _,stack in pairs(self.getAvailableItems('all')) do