diff --git a/src/adv/Adv.lua b/src/adv/Adv.lua index 2b587ff..9f76419 100644 --- a/src/adv/Adv.lua +++ b/src/adv/Adv.lua @@ -1127,10 +1127,17 @@ function Adv:supplyPotion() for potionId, set in pairs(potionCsv) do local count = potionBag[potionId] or 0 if count > 0 then - local level = dishTree:getv(potionId,1) - local num = math.min(set[level].limit,count) - advItems = advItems:setv(potionId,num) - potionBag[potionId] = num ~= count and (count - num) or nil + local max = set[dishTree:getv(potionId,1)].limit + local old = advItems:getv(potionId,0) + local need = max - old + + if need < count then + advItems = advItems:setv(potionId,max) + potionBag[potionId] = count - need + else + advItems = advItems:setv(potionId,old + count) + potionBag[potionId] = nil + end end end self.owner:updateProperties({ -- libgit2 0.21.2