Use Enums instead of hardcoded values

This commit is contained in:
Robin Hüskes 2022-11-21 03:41:01 +01:00
parent 1a35bcdfbf
commit 8df041f9e9
1 changed files with 3 additions and 3 deletions

View File

@ -18,7 +18,7 @@ function child:scanBag(bag)
if(item) then if(item) then
local itemInfo = C_Container.GetContainerItemInfo(bag, slot) local itemInfo = C_Container.GetContainerItemInfo(bag, slot)
local id = item:GetItemID() local id = item:GetItemID()
if(id) then if(itemInfo and id) then
empty = false empty = false
itemlist[id] = itemlist[id] or {} itemlist[id] = itemlist[id] or {}
itemlist[id]['count'] = itemlist[id]['count'] or 0 itemlist[id]['count'] = itemlist[id]['count'] or 0
@ -35,11 +35,11 @@ local function scanAllBags(delayed)
local playerID = child.getPID() local playerID = child.getPID()
if(playerID) then if(playerID) then
local tab = modul['db'][playerID] local tab = modul['db'][playerID]
for bag=0,4 do for bag=Enum.BagIndex.Backpack ,Enum.BagIndex.ReagentBag do
tab[bag] = child:scanBag(bag) -- loop all bought bags tab[bag] = child:scanBag(bag) -- loop all bought bags
end end
for k,v in pairs(modul['db'][playerID]) do for k,v in pairs(modul['db'][playerID]) do
if(k<0 or k>4) then if(k<Enum.BagIndex.Backpack or k>Enum.BagIndex.ReagentBag) then
tab[k] = nil -- prevent bogus bags tab[k] = nil -- prevent bogus bags
end end
end end