storage refactor - void option

This commit is contained in:
kepler155c
2018-10-26 16:08:07 -04:00
parent 6dde2245a6
commit f9ae197cfc
11 changed files with 321 additions and 318 deletions

View File

@@ -11,7 +11,7 @@ local craftTask = {
}
function craftTask:craftItem(recipe, item, count)
Craft.craftRecipe(recipe, count, context.inventoryAdapter, item)
Craft.craftRecipe(recipe, count, context.storage, item)
Milo:clearGrid()
end
@@ -73,7 +73,7 @@ function craftTask:forceCraftItem(inRecipe, originalItem, inCount)
if craftable > 0 then
craftable = Craft.craftRecipe(recipe, craftable * recipe.count,
context.inventoryAdapter, originalItem) / recipe.count
context.storage, originalItem) / recipe.count
Milo:clearGrid()
end

View File

@@ -25,11 +25,11 @@ function ExportTask:cycle(context)
if count > 0 then
item = Milo:getItemWithQty(item)
if item and count > 0 then
context.inventoryAdapter:provide(
item,
math.min(count, item.count),
context.storage:export(
target,
entry.slot,
target)
math.min(count, item.count),
item)
end
end
end

View File

@@ -10,12 +10,12 @@ local ImportTask = {
function ImportTask:cycle(context)
for source, v in pairs(context.config.remoteDefaults) do
if v.imports then
local machine = device[source]
if machine and machine.getItemMeta then
for slotNo in pairs(v.imports) do
local slot = machine.getItemMeta(slotNo)
if slot then
context.inventoryAdapter:insert(slotNo, slot.count, nil, slot, source)
local inventory = device[source]
if inventory and inventory.getItemMeta then
for slot in pairs(v.imports) do
local item = inventory.getItemMeta(slot)
if item then
context.storage:import(source, slot, item.count, item)
end
end
else

View File

@@ -8,14 +8,14 @@ local InputChest = {
}
function InputChest:cycle(context)
for name,v in pairs(context.config.remoteDefaults) do
for source,v in pairs(context.config.remoteDefaults) do
if v.mtype == 'input' then
local inventory = device[name]
local inventory = device[source]
local list = inventory and inventory.list and inventory.list()
if list then
for slotNo, slot in pairs(list) do
context.inventoryAdapter:insert(slotNo, slot.count, nil, slot, name)
for slot, item in pairs(list) do
context.storage:import(source, slot, item.count, item)
end
end
end

View File

@@ -23,11 +23,11 @@ function LimitTask:cycle(context)
if res.limit then
local item = Milo:getItemWithQty(res, res.ignoreDamage, res.ignoreNbtHash)
if item and item.count > res.limit then
context.inventoryAdapter:provide(
{ name = item.name, damage = item.damage, nbtHash = item.nbtHash },
item.count - res.limit,
context.storage:export(
trashcan,
nil,
trashcan)
item.count - res.limit,
item)
end
end
end

View File

@@ -12,9 +12,9 @@ function PotionImportTask:cycle(context)
if v.type == 'minecraft:brewing_stand' and v.getBrewTime() == 0 then
local list = v.list()
if not list[4] then
for i = 1, 3 do
if list[i] then
context.inventoryAdapter:insert(i, 1, nil, list[i], v.name)
for slot = 1, 3 do
if list[slot] then
context.storage:import(v.name, slot, 1, list[slot])
end
end
end

View File

@@ -47,11 +47,11 @@ local function client(socket)
Milo:clearGrid()
elseif data.request == 'transfer' then
local count = context.inventoryAdapter:provide(
data.item,
data.count,
local count = context.storage:export(
context.localName,
nil,
context.localName)
data.count,
data.item)
turtle.eachFilledSlot(function(slot)
manipulator.getInventory().pullItems(