milo: refresh interval
This commit is contained in:
@@ -177,6 +177,7 @@ function Storage:listItems(throttle)
|
|||||||
local timer = Timer()
|
local timer = Timer()
|
||||||
for _, adapter in self:onlineAdapters() do
|
for _, adapter in self:onlineAdapters() do
|
||||||
if adapter.dirty then
|
if adapter.dirty then
|
||||||
|
_G._debug('STORAGE: refreshing ' .. adapter.name)
|
||||||
adapter:listItems(throttle)
|
adapter:listItems(throttle)
|
||||||
adapter.dirty = false
|
adapter.dirty = false
|
||||||
end
|
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.
|
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 {
|
local brewingStandView = UI.Window {
|
||||||
title = 'Brewing Stand',
|
title = 'Brewing Stand',
|
||||||
|
|||||||
@@ -8,9 +8,22 @@ local RefreshTask = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function RefreshTask:cycle(context)
|
function RefreshTask:cycle(context)
|
||||||
if os.clock() - context.storage.lastRefresh > 60 then
|
local now = os.clock()
|
||||||
context.storage:refresh()
|
|
||||||
|
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
|
end
|
||||||
|
|
||||||
|
-- if os.clock() - context.storage.lastRefresh > 60 then
|
||||||
|
-- context.storage:refresh()
|
||||||
|
-- end
|
||||||
end
|
end
|
||||||
|
|
||||||
Milo:registerTask(RefreshTask)
|
Milo:registerTask(RefreshTask)
|
||||||
|
|||||||
@@ -9,23 +9,35 @@ local storageView = UI.Window {
|
|||||||
index = 2,
|
index = 2,
|
||||||
backgroundColor = colors.cyan,
|
backgroundColor = colors.cyan,
|
||||||
form = UI.Form {
|
form = UI.Form {
|
||||||
x = 1, y = 2, ex = -1, ey = -2,
|
x = 1, y = 1, ex = -1, ey = -2,
|
||||||
manualControls = true,
|
manualControls = true,
|
||||||
[1] = UI.TextEntry {
|
[1] = UI.TextEntry {
|
||||||
formLabel = 'Priority', formKey = 'priority',
|
formLabel = 'Priority', formKey = 'priority',
|
||||||
help = 'Larger values get precedence',
|
help = 'Larger values get precedence',
|
||||||
limit = 4,
|
limit = 4,
|
||||||
validate = 'numeric', pruneEmpty = true,
|
validate = 'numeric',
|
||||||
|
shadowText = 'Numeric priority',
|
||||||
},
|
},
|
||||||
[2] = UI.Checkbox {
|
[2] = UI.Checkbox {
|
||||||
formLabel = 'Locked', formKey = 'lockWith',
|
formLabel = 'Locked', formKey = 'lockWith',
|
||||||
help = 'Locks chest to a single item type',
|
help = 'Locks chest to a single item type',
|
||||||
pruneEmpty = true,
|
|
||||||
},
|
},
|
||||||
[3] = UI.Text {
|
[3] = UI.Text {
|
||||||
x = 16, ex = -2, y = 3,
|
x = 16, ex = -2, y = 3,
|
||||||
value = '',
|
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 {
|
[4] = UI.Checkbox {
|
||||||
formLabel = 'Void', formKey = 'voidExcess',
|
formLabel = 'Void', formKey = 'voidExcess',
|
||||||
|
|||||||
Reference in New Issue
Block a user