milo: refresh interval
This commit is contained in:
@@ -177,6 +177,7 @@ function Storage:listItems(throttle)
|
||||
local timer = Timer()
|
||||
for _, adapter in self:onlineAdapters() do
|
||||
if adapter.dirty then
|
||||
_G._debug('STORAGE: refreshing ' .. adapter.name)
|
||||
adapter:listItems(throttle)
|
||||
adapter.dirty = false
|
||||
end
|
||||
|
||||
@@ -13,7 +13,7 @@ Simply craft potions in the brewing stand as normal except for these conditions.
|
||||
|
||||
When finished brewing, the recipe will be available upon refreshing.
|
||||
|
||||
Note that you do not need to import items from the brewing stand, this will be done automatically.]]
|
||||
Note that you do not need to import items from the brewing stand or export blaze powder, this will be done automatically.]]
|
||||
|
||||
local brewingStandView = UI.Window {
|
||||
title = 'Brewing Stand',
|
||||
|
||||
@@ -8,9 +8,22 @@ local RefreshTask = {
|
||||
}
|
||||
|
||||
function RefreshTask:cycle(context)
|
||||
if os.clock() - context.storage.lastRefresh > 60 then
|
||||
context.storage:refresh()
|
||||
local now = os.clock()
|
||||
|
||||
for node, adapter in context.storage:onlineAdapters() do
|
||||
if node.refreshInterval then
|
||||
if not adapter.lastRefresh or adapter.lastRefresh + node.refreshInterval < now then
|
||||
_G._debug('REFRESHER: ' .. adapter.name)
|
||||
context.storage.dirty = true
|
||||
adapter.dirty = true
|
||||
adapter.lastRefresh = now
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- if os.clock() - context.storage.lastRefresh > 60 then
|
||||
-- context.storage:refresh()
|
||||
-- end
|
||||
end
|
||||
|
||||
Milo:registerTask(RefreshTask)
|
||||
|
||||
@@ -9,23 +9,35 @@ local storageView = UI.Window {
|
||||
index = 2,
|
||||
backgroundColor = colors.cyan,
|
||||
form = UI.Form {
|
||||
x = 1, y = 2, ex = -1, ey = -2,
|
||||
x = 1, y = 1, ex = -1, ey = -2,
|
||||
manualControls = true,
|
||||
[1] = UI.TextEntry {
|
||||
formLabel = 'Priority', formKey = 'priority',
|
||||
help = 'Larger values get precedence',
|
||||
limit = 4,
|
||||
validate = 'numeric', pruneEmpty = true,
|
||||
validate = 'numeric',
|
||||
shadowText = 'Numeric priority',
|
||||
},
|
||||
[2] = UI.Checkbox {
|
||||
formLabel = 'Locked', formKey = 'lockWith',
|
||||
help = 'Locks chest to a single item type',
|
||||
pruneEmpty = true,
|
||||
},
|
||||
[3] = UI.Text {
|
||||
x = 16, ex = -2, y = 3,
|
||||
value = '',
|
||||
},
|
||||
[4] = UI.TextEntry {
|
||||
formLabel = 'Refresh', formKey = 'refreshInterval',
|
||||
help = 'Refresh periodically',
|
||||
limit = 4,
|
||||
validate = 'numeric',
|
||||
shadowText = 'seconds between refresh',
|
||||
},
|
||||
[5] = UI.TextArea {
|
||||
x = 12, ex = -2, y = 5,
|
||||
textColor = colors.yellow,
|
||||
value = 'Only specify if you are manually taking items out of this inventory. Value should be > 10',
|
||||
},
|
||||
--[[
|
||||
[4] = UI.Checkbox {
|
||||
formLabel = 'Void', formKey = 'voidExcess',
|
||||
|
||||
Reference in New Issue
Block a user