mirror of
https://github.com/kepler155c/opus
synced 2025-10-21 10:47:40 +00:00
storage activity wrong amounts
This commit is contained in:
@@ -5,14 +5,12 @@ local TableDB = require('tableDB')
|
||||
local RefinedProvider = class()
|
||||
|
||||
local keys = {
|
||||
'fields',
|
||||
'damage',
|
||||
'displayName',
|
||||
'maxCount',
|
||||
'maxDamage',
|
||||
'name',
|
||||
'nbtHash',
|
||||
'rawName',
|
||||
}
|
||||
|
||||
function RefinedProvider:init(args)
|
||||
@@ -78,6 +76,8 @@ function RefinedProvider:getCachedItemDetails(item)
|
||||
|
||||
detail = t
|
||||
self.itemInfoDB:add(key, detail)
|
||||
|
||||
os.sleep(0) -- prevent timeout on large inventories
|
||||
end
|
||||
end
|
||||
if detail then
|
||||
@@ -94,6 +94,9 @@ function RefinedProvider:listItems()
|
||||
end)
|
||||
|
||||
if list then
|
||||
|
||||
local throttle = Util.throttle()
|
||||
|
||||
for _,v in pairs(list) do
|
||||
local item = self:getCachedItemDetails(v)
|
||||
if item then
|
||||
@@ -103,6 +106,7 @@ function RefinedProvider:listItems()
|
||||
item.qty = v.count
|
||||
table.insert(items, item)
|
||||
end
|
||||
throttle()
|
||||
end
|
||||
self.itemInfoDB:flush()
|
||||
end
|
||||
|
@@ -21,6 +21,17 @@ function Util.tryTimes(attempts, f, ...)
|
||||
return unpack(result)
|
||||
end
|
||||
|
||||
function Util.throttle()
|
||||
local ts = os.time()
|
||||
return function()
|
||||
local nts = os.time()
|
||||
if nts ~= ts then
|
||||
ts = nts
|
||||
os.sleep(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Util.tostring(pattern, ...)
|
||||
|
||||
local function serialize(tbl, width)
|
||||
|
Reference in New Issue
Block a user