milo wip
This commit is contained in:
@@ -132,10 +132,11 @@ end
|
||||
function Milo:getTurtleInventory()
|
||||
local list = { }
|
||||
for i = 1,16 do
|
||||
-- TODO: update item db
|
||||
local item = self.context.introspectionModule.getInventory().getItemMeta(i)
|
||||
if item then
|
||||
itemDB:add(item)
|
||||
if not itemDB:get(item) then
|
||||
itemDB:add(item)
|
||||
end
|
||||
list[i] = item
|
||||
end
|
||||
end
|
||||
@@ -211,7 +212,8 @@ function Milo:mergeResources(t)
|
||||
item = Util.shallowCopy(v)
|
||||
item.count = 0
|
||||
item.key = self:uniqueKey(v)
|
||||
table.insert(t, item)
|
||||
-- table.insert(t, item)
|
||||
t[item.key] = item
|
||||
end
|
||||
end
|
||||
|
||||
@@ -222,11 +224,19 @@ function Milo:mergeResources(t)
|
||||
item = Util.shallowCopy(v)
|
||||
item.count = 0
|
||||
item.key = self:uniqueKey(v)
|
||||
table.insert(t, item)
|
||||
t[item.key] = item
|
||||
-- table.insert(t, item)
|
||||
end
|
||||
item.has_recipe = true
|
||||
end
|
||||
|
||||
for key in pairs(Craft.machineLookup) do
|
||||
local item = t[key]
|
||||
if item then
|
||||
item.is_craftable = true
|
||||
end
|
||||
end
|
||||
|
||||
for _,v in pairs(t) do
|
||||
if not v.displayName then
|
||||
v.displayName = itemDB:getName(v)
|
||||
|
||||
@@ -44,7 +44,7 @@ function Storage:showStorage()
|
||||
end
|
||||
end
|
||||
if #t > 0 then
|
||||
debug('Storage:')
|
||||
debug('Adapter:')
|
||||
for _, k in pairs(t) do
|
||||
debug(' offline: ' .. k)
|
||||
end
|
||||
@@ -164,7 +164,6 @@ debug('STORAGE: refresh: ' .. adapter.name)
|
||||
adapter.dirty = false
|
||||
end
|
||||
local rcache = adapter.cache or { }
|
||||
-- TODO: add a method in each adapter that only updates a passed cache
|
||||
for key,v in pairs(rcache) do
|
||||
local entry = cache[key]
|
||||
if not entry then
|
||||
@@ -172,7 +171,8 @@ debug('STORAGE: refresh: ' .. adapter.name)
|
||||
entry.count = v.count
|
||||
entry.key = key
|
||||
cache[key] = entry
|
||||
table.insert(items, entry)
|
||||
items[key] = entry
|
||||
-- table.insert(items, entry)
|
||||
else
|
||||
entry.count = entry.count + v.count
|
||||
end
|
||||
@@ -215,7 +215,7 @@ function Storage:provide(item, qty, slot, direction)
|
||||
end
|
||||
end
|
||||
|
||||
debug('miss: %s - %d', key, qty)
|
||||
debug('STORAGE: MISS: %s - %d', key, qty)
|
||||
self.misses = self.misses + 1
|
||||
|
||||
for _, adapter in self:onlineAdapters() do
|
||||
|
||||
Reference in New Issue
Block a user