Fix reagentCount show up in output

This commit is contained in:
rilgamon 2021-04-04 15:56:03 +02:00
parent 847e79250d
commit ae0561c9a4
1 changed files with 11 additions and 11 deletions

View File

@ -9,6 +9,7 @@ local modul = {
}
local db
local desc = format('%sCount', modulname)
local desc2 = 'reagentCount'
local BankIsOpen = false
function modul.Guess(id)
local dbcount = modul.Get(id)
@ -84,7 +85,7 @@ local function bagLoop(id, res)
if(playerID and units[k]['faction'] == units[playerID]['faction']) then
local unitname = units[k]['name']
for bag, list in pairs(v) do
dName = bag == -3 and 'reagentCount' or desc
dName = (bag == -3) and desc2 or desc
for a, b in pairs(list) do
if(a == id) then
res[unitname] = res[unitname] or {
@ -142,22 +143,21 @@ local function OnEvent(self, event, ...)
events[event](self, event, ...)
end
end
function modul.Search(id,res)
function modul.Search(id, res)
local playerID = child.getPID()
if(playerID) then
modul['db'][playerID] = modul['db'][playerID] or {}
end
return playerID and bagLoop(id,res) or res
return playerID and bagLoop(id, res) or res
end
function modul.Output(input,sum,b)
if(b[desc] and b[desc]>0) then
input[#input+1] = format("Bank %s",b[desc])
sum = sum + b[desc]
function modul.Output(input, sum, b)
if(b[desc] and b[desc] > 0) then
input[#input+1] = format("Bank %s", b[desc])
sum = sum + b[desc]
end
desc = 'reagentCount'
if(b[desc] and b[desc]>0) then
input[#input+1] = format("Reagents %s",b[desc])
sum = sum + b[desc]
if(b[desc2] and b[desc2] > 0) then
input[#input+1] = format("Reagents %s", b[desc2])
sum = sum + b[desc2]
end
return input,sum
end