Add furniController.lua #37

Merged
drucifer-sc merged 13 commits from develop-1.8 into develop-1.8 2020-05-24 00:09:23 -04:00
Showing only changes of commit 2873401782 - Show all commits

View File

@@ -66,11 +66,12 @@ function ExportTask:cycle(context)
end
local function exportItems()
node.cacheList = node.adapter.list()
local cache,size={node.adapter.list(),node.adapter.size()} -- Make single calls, not repeat
local cacheSize=Util.size(cache) -- Same, though this call doesn't hurt as bad
for key in pairs(entry.filter) do
local items = Milo:getMatches(itemDB:splitKey(key), entry)
for _,item in pairs(items) do
if node.adapter.size() ~= Util.size(node.cacheList) then
if size ~= cacheSize then
-- Here we have a storage which has at least 1 unpopulated slot, we can fire'n'forget into this
if context.storage:export(node, nil, item.count, item) == 0 then
-- TODO: really shouldn't break here as there may be room in other slots
@@ -79,19 +80,21 @@ function ExportTask:cycle(context)
end
else
-- Here we have a storage with all slots occupied, sort through and find open spaces
for iNum,_ in ipairs(node.cacheList) do
local slot = node.adapter.getItemMeta(iNum)
if (slot.name == filterItem.name and slot.count ~= slot.maxCount and
(entry.ignoreDamage or slot.damage == filterItem.damage) and
(entry.ignoreNbtHash or slot.nbtHash == filterItem.nbtHash)) then
-- We found a slot that matches, and is not full, let's export to it!
context.storage:export(node, iNum, math.min(slot.maxCount-slot.count,item.count), item)
for iNum=1,size do
local slot = cache[i]
if slot then
if (slot.name == item.name and slot.count ~= item.maxCount and
(entry.ignoreDamage or slot.damage == item.damage) and
(entry.ignoreNbtHash or slot.nbtHash == item.nbtHash)) then
-- We found a slot that matches, and is not full, let's export to it!
-- Reworked to use item's .maxCount against the existing .list()[slot].count instead of repeat .getItemMeta calls
context.storage:export(node, iNum, math.min(item.maxCount-slot.count,item.count), item)
end
end
end
end
end
end
node.cacheList=nil
end
if type(entry.slot) == 'number' then
exportSingleSlot()