milo wip
This commit is contained in:
@@ -13,7 +13,6 @@ function NetworkedAdapter:init(args)
|
|||||||
dirty = true,
|
dirty = true,
|
||||||
listCount = 0,
|
listCount = 0,
|
||||||
activity = { },
|
activity = { },
|
||||||
nameArray = { },
|
|
||||||
}
|
}
|
||||||
Util.merge(self, defaults)
|
Util.merge(self, defaults)
|
||||||
Util.merge(self, args)
|
Util.merge(self, args)
|
||||||
@@ -30,7 +29,6 @@ listCount = 0,
|
|||||||
local adapter = InventoryAdapter.wrap({ side = k, direction = self.localName })
|
local adapter = InventoryAdapter.wrap({ side = k, direction = self.localName })
|
||||||
if adapter then
|
if adapter then
|
||||||
table.insert(self.remotes, adapter)
|
table.insert(self.remotes, adapter)
|
||||||
self.nameArray[adapter.direction] = true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -49,7 +47,6 @@ listCount = 0,
|
|||||||
return a.priority > b.priority
|
return a.priority > b.priority
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
debug(self.nameArray)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function NetworkedAdapter:isValid()
|
function NetworkedAdapter:isValid()
|
||||||
@@ -113,7 +110,6 @@ function NetworkedAdapter:getItemInfo(item)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function NetworkedAdapter:provide(item, qty, slot, direction)
|
function NetworkedAdapter:provide(item, qty, slot, direction)
|
||||||
local key = table.concat({ item.name, item.damage, item.nbtHash }, ':')
|
|
||||||
local total = 0
|
local total = 0
|
||||||
|
|
||||||
for _, remote in ipairs(self.remotes) do
|
for _, remote in ipairs(self.remotes) do
|
||||||
@@ -124,10 +120,6 @@ debug('EXT: %s(%d): %s -> %s%s',
|
|||||||
slot and string.format('[%d]', slot) or '')
|
slot and string.format('[%d]', slot) or '')
|
||||||
self.dirty = true
|
self.dirty = true
|
||||||
remote.dirty = true
|
remote.dirty = true
|
||||||
--if self.nameArray[direction or self.localName] then
|
|
||||||
-- local entry = self.activity[key] or 0
|
|
||||||
-- self.activity[key] = entry + amount
|
|
||||||
--end
|
|
||||||
end
|
end
|
||||||
qty = qty - amount
|
qty = qty - amount
|
||||||
total = total + amount
|
total = total + amount
|
||||||
@@ -179,10 +171,8 @@ debug('INS: %s(%d): %s[%d] -> %s',
|
|||||||
self.dirty = true
|
self.dirty = true
|
||||||
remote.dirty = true
|
remote.dirty = true
|
||||||
debug('insert: ' .. (source or self.localName))
|
debug('insert: ' .. (source or self.localName))
|
||||||
--if self.nameArray[source or self.localName] then
|
local entry = self.activity[key] or 0
|
||||||
local entry = self.activity[key] or 0
|
self.activity[key] = entry + amount
|
||||||
self.activity[key] = entry + amount
|
|
||||||
--end
|
|
||||||
end
|
end
|
||||||
qty = qty - amount
|
qty = qty - amount
|
||||||
total = total + amount
|
total = total + amount
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ local function machineCraft(recipe, qty, inventoryAdapter, machineName, oitem)
|
|||||||
local key = recipe.result
|
local key = recipe.result
|
||||||
local request = oitem.ingredients[key]
|
local request = oitem.ingredients[key]
|
||||||
|
|
||||||
debug('requested: ' .. key)
|
|
||||||
if not request then
|
if not request then
|
||||||
request = {
|
request = {
|
||||||
count = qty,
|
count = qty,
|
||||||
@@ -75,7 +74,6 @@ debug('requested: ' .. key)
|
|||||||
|
|
||||||
if request.pending then
|
if request.pending then
|
||||||
request.crafted = request.crafted + (inventoryAdapter.activity[key] or 0)
|
request.crafted = request.crafted + (inventoryAdapter.activity[key] or 0)
|
||||||
debug({ request.crafted, request.count })
|
|
||||||
if request.crafted >= request.count then
|
if request.crafted >= request.count then
|
||||||
request.pending = nil -- TODO: check...
|
request.pending = nil -- TODO: check...
|
||||||
request.statusCode = Craft.STATUS_SUCCESS
|
request.statusCode = Craft.STATUS_SUCCESS
|
||||||
@@ -100,8 +98,6 @@ debug({ request.crafted, request.count })
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
debug('processing %s %d', key, qty)
|
|
||||||
|
|
||||||
for k,v in pairs(recipe.ingredients) do
|
for k,v in pairs(recipe.ingredients) do
|
||||||
if inventoryAdapter:provide(splitKey(v), qty, k, machineName) ~= qty then
|
if inventoryAdapter:provide(splitKey(v), qty, k, machineName) ~= qty then
|
||||||
-- TODO: suck em back out
|
-- TODO: suck em back out
|
||||||
@@ -119,7 +115,6 @@ local function turtleCraft(recipe, qty, inventoryAdapter, oitem)
|
|||||||
local key = recipe.result
|
local key = recipe.result
|
||||||
local request = oitem.ingredients[key]
|
local request = oitem.ingredients[key]
|
||||||
|
|
||||||
debug('requested: ' .. key)
|
|
||||||
if not request then
|
if not request then
|
||||||
request = {
|
request = {
|
||||||
count = qty,
|
count = qty,
|
||||||
|
|||||||
Reference in New Issue
Block a user