Cleanup code
This commit is contained in:
parent
07687e1b03
commit
ec7cffd606
|
@ -17,8 +17,8 @@ local function scanVoid()
|
||||||
if(playerID) then
|
if(playerID) then
|
||||||
local itemlist = {}
|
local itemlist = {}
|
||||||
local empty = true
|
local empty = true
|
||||||
for tab=1,2 do
|
for tab = 1, 2 do
|
||||||
for slot=1,80 do
|
for slot = 1, 80 do
|
||||||
local id, icon = GetVoidItemInfo(tab, slot)
|
local id, icon = GetVoidItemInfo(tab, slot)
|
||||||
if(id) then
|
if(id) then
|
||||||
id = tonumber(id)
|
id = tonumber(id)
|
||||||
|
@ -31,10 +31,10 @@ local function scanVoid()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local count = 0
|
local count = 0
|
||||||
for k,v in pairs(itemlist) do
|
for k, v in pairs(itemlist) do
|
||||||
count = count + 1
|
count = count + 1
|
||||||
end
|
end
|
||||||
if(count==0 and failCount<3) then
|
if(count == 0 and failCount < 3) then
|
||||||
C_Timer.After(.2, scanVoid)
|
C_Timer.After(.2, scanVoid)
|
||||||
failCount = failCount + 1
|
failCount = failCount + 1
|
||||||
return
|
return
|
||||||
|
@ -43,7 +43,6 @@ local function scanVoid()
|
||||||
modul['db'][playerID][0] = itemlist
|
modul['db'][playerID][0] = itemlist
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function bagLoop(id, res)
|
local function bagLoop(id, res)
|
||||||
for k, v in pairs(modul['db']) do
|
for k, v in pairs(modul['db']) do
|
||||||
local units = child:GetNamespace('units')
|
local units = child:GetNamespace('units')
|
||||||
|
@ -71,14 +70,14 @@ function modul.Search(id, res)
|
||||||
if(playerID) then
|
if(playerID) then
|
||||||
modul['db'][playerID] = modul['db'][playerID] or {}
|
modul['db'][playerID] = modul['db'][playerID] or {}
|
||||||
end
|
end
|
||||||
return playerID and bagLoop(id,res) or res
|
return playerID and bagLoop(id, res) or res
|
||||||
end
|
end
|
||||||
function modul.Output(input, sum, b)
|
function modul.Output(input, sum, b)
|
||||||
if(b[dName] and b[dName]>0) then
|
if(b[dName] and b[dName]>0) then
|
||||||
input[#input+1] = format("Void %s",b[dName])
|
input[#input + 1] = format("Void %s", b[dName])
|
||||||
sum = sum + b[dName]
|
sum = sum + b[dName]
|
||||||
end
|
end
|
||||||
return input,sum
|
return input, sum
|
||||||
end
|
end
|
||||||
function events:VOID_STORAGE_CLOSE()
|
function events:VOID_STORAGE_CLOSE()
|
||||||
voidOpen = false
|
voidOpen = false
|
||||||
|
@ -93,7 +92,6 @@ events.ITEM_UNLOCKED = scanVoid
|
||||||
events.VOID_TRANSFER_DONE = scanVoid
|
events.VOID_TRANSFER_DONE = scanVoid
|
||||||
local function OnEvent(self, event, ...)
|
local function OnEvent(self, event, ...)
|
||||||
local playerID = child.getPID()
|
local playerID = child.getPID()
|
||||||
-- print(modulname, event, ...)
|
|
||||||
if(playerID and type(events[event])=='function') then
|
if(playerID and type(events[event])=='function') then
|
||||||
modul['db'] = child:GetNamespace(modul.name)
|
modul['db'] = child:GetNamespace(modul.name)
|
||||||
modul['db'][playerID] = modul['db'][playerID] or {}
|
modul['db'][playerID] = modul['db'][playerID] or {}
|
||||||
|
@ -109,7 +107,7 @@ end
|
||||||
function modul:Enable()
|
function modul:Enable()
|
||||||
self['status'] = true
|
self['status'] = true
|
||||||
local list = {}
|
local list = {}
|
||||||
for event,func in pairs(events) do
|
for event, func in pairs(events) do
|
||||||
list[#list+1] = event
|
list[#list+1] = event
|
||||||
end
|
end
|
||||||
for i = 1, #list do
|
for i = 1, #list do
|
||||||
|
@ -128,7 +126,7 @@ child:IgnoreBCC(modulname)
|
||||||
local init = {
|
local init = {
|
||||||
Setup = function(self)
|
Setup = function(self)
|
||||||
db = child['db']
|
db = child['db']
|
||||||
modul.db,modul.status = child:RegisterModul(modul, modulname)
|
modul.db, modul.status = child:RegisterModul(modul, modulname)
|
||||||
if(modul.status) then
|
if(modul.status) then
|
||||||
modul:Enable()
|
modul:Enable()
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue