Files
opus-apps/milo/plugins/replenishTask.lua
kepler155c 9f9dcafc60 milo wip
2018-10-25 05:51:46 -04:00

40 lines
916 B
Lua

local itemDB = require('itemDB')
local Milo = require('milo')
local ReplenishTask = {
name = 'replenish',
priority = 60,
}
function ReplenishTask:cycle(context)
for _,res in pairs(context.resources) do
if res.low then
local item = Milo:getItemWithQty(res, res.ignoreDamage, res.ignoreNbtHash)
if not item then
item = {
damage = res.damage,
nbtHash = res.nbtHash,
name = res.name,
displayName = itemDB:getName(res),
count = 0
}
end
if item.count < res.low then
if res.ignoreDamage then
item.damage = 0
end
Milo:requestCrafting({
damage = item.damage,
nbtHash = item.nbtHash,
count = res.low - item.count,
name = item.name,
displayName = item.displayName,
})
end
end
end
end
Milo:registerTask(ReplenishTask)