Files
opus-apps/milo/plugins/limitTask.lua
kepler155c 6ce4039e8a milo wip
2018-10-25 00:18:38 -04:00

37 lines
697 B
Lua

local Milo = require('milo')
local LimitTask = {
name = 'limiter',
priority = 50,
}
function LimitTask:cycle(context)
local trashcan
for k,v in pairs(context.config.remoteDefaults) do
if v.mtype == 'trashcan' then
trashcan = k
break
end
end
if not trashcan then
return
end
for _,res in pairs(context.resources) do
if res.limit then
local item = Milo:getItemWithQty(res, res.ignoreDamage, res.ignoreNbtHash)
if item and item.count > res.limit then
context.inventoryAdapter:provide(
{ name = item.name, damage = item.damage, nbtHash = item.nbtHash },
item.count - res.limit,
nil,
trashcan)
end
end
end
end
Milo:registerTask(LimitTask)