Skip inactive modules for searches

This commit is contained in:
rilgamon 2021-04-04 15:22:38 +02:00
parent 5d38d18b13
commit 1c3086c878
6 changed files with 20 additions and 17 deletions

View File

@ -8,6 +8,7 @@ local modul = {
['name'] = modulname
}
local db
local desc = format('%sCount', modulname)
function child:scanBag(bag)
local slot = 1
local itemlist = {}
@ -45,21 +46,20 @@ local function scanAllBags(delayed)
end
end
local function bagLoop(id, res)
local dName = modulname.."Count"
for k,v in pairs(modul['db']) do
for k, v in pairs(modul['db']) do
local units = child:GetNamespace('units')
if(units[k]) then
local playerID = child.getPID()
if(playerID and units[k]['faction'] == units[playerID]['faction']) then
local unitname = units[k]['name']
for bag,list in pairs(v) do
for a,b in pairs(list) do
for bag, list in pairs(v) do
for a, b in pairs(list) do
if(a == id) then
res[unitname] = res[unitname] or {
[dName] = 0
[desc] = 0
}
res[unitname][dName] = res[unitname][dName] or 0
res[unitname][dName] = res[unitname][dName] + b['count']
res[unitname][desc] = res[unitname][desc] or 0
res[unitname][desc] = res[unitname][desc] + b['count']
end
end
end
@ -69,6 +69,7 @@ local function bagLoop(id, res)
return res
end
function modul.Search(id, res)
if(not module.status) then return res end
local playerID = child.getPID()
if(playerID) then
modul['db'][playerID] = modul['db'][playerID] or {}
@ -76,12 +77,11 @@ function modul.Search(id, res)
return playerID and bagLoop(id, res) or res
end
function modul.Output(input, sum, b)
local desc = modulname..'Count'
if(b[desc] and b[desc]>0) then
if(b[desc] and b[desc] > 0) then
input[#input+1] = format("Bags %s",b[desc])
sum = sum + b[desc]
end
return input,sum
return input, sum
end
function events:ITEM_UNLOCKED(event,...)
scanAllBags(nil)

View File

@ -8,6 +8,7 @@ local modul = {
['name'] = modulname
}
local db
local desc = format('%sCount', modulname)
local BankIsOpen = false
function modul.Guess(id)
local dbcount = modul.Get(id)
@ -75,8 +76,7 @@ local function scanAllBankBags(delayed)
end
end
local function bagLoop(id, res)
local cName = format("%sCount", modulname)
local dName = cName
local dName = desc
for k,v in pairs(modul['db']) do
local units = child:GetNamespace('units')
if(units[k]) then
@ -87,7 +87,7 @@ local function bagLoop(id, res)
if(bag == -3) then
dName = 'reagentCount'
else
dName = cName
dName = desc
end
for a, b in pairs(list) do
if(a == id) then
@ -105,8 +105,7 @@ local function bagLoop(id, res)
return res
end
function modul.Get(id)
local cName = format("%sCount", modulname)
local dName = cName
local dName = desc
local res = 0
local playerID = child.getPID()
for k, v in pairs(modul['db']) do
@ -148,6 +147,7 @@ local function OnEvent(self, event, ...)
end
end
function modul.Search(id,res)
if(not module.status) then return res end
local playerID = child.getPID()
if(playerID) then
modul['db'][playerID] = modul['db'][playerID] or {}
@ -155,7 +155,6 @@ function modul.Search(id,res)
return playerID and bagLoop(id,res) or res
end
function modul.Output(input,sum,b)
local desc = format('%sCount', modulname)
if(b[desc] and b[desc]>0) then
input[#input+1] = format("Bank %s",b[desc])
sum = sum + b[desc]

View File

@ -73,7 +73,8 @@ local function bagLoop(id,res)
end
return res
end
function modul.Search(id,res)
function modul.Search(id, res)
if(not module.status) then return res end
local playerID = child.getPID()
if(playerID) then
modul['db'][playerID] = modul['db'][playerID] or {}

View File

@ -72,6 +72,7 @@ local function gbagLoop(id)
return res
end
function modul.Search2(id, res, mode)
if(not module.status) then return res end
local guildID = child.getGID()
if(guildID) then
modul['db'][guildID] = modul['db'][guildID] or {}

View File

@ -123,6 +123,7 @@ local function bagLoop(id, res)
return res
end
function modul.Search(id, res)
if(not module.status) then return res end
local playerID = child.getPID()
if(playerID) then
modul['db'][playerID] = modul['db'][playerID] or {}

View File

@ -67,6 +67,7 @@ local function bagLoop(id, res)
return res
end
function modul.Search(id, res)
if(not module.status) then return res end
local playerID = child.getPID()
if(playerID) then
modul['db'][playerID] = modul['db'][playerID] or {}