diff --git a/pError/pError.lua b/pError/pError.lua
index 9f2f979..e36409f 100644
--- a/pError/pError.lua
+++ b/pError/pError.lua
@@ -10,62 +10,42 @@
--]]
local next = next
-local find = string.find
-local lower = string.lower
+local find, lower = string.find, string.lower
+local pError = CreateFrame('Frame')
local orig = UIErrorsFrame:GetScript('OnEvent')
-local function msg(...)
- print(format('|cffff8080pError:|r %s', ...))
-end
-
local function slashCommand(str)
- str = lower(str)
-
if(str == 'reset') then
- pErrorDB = {all = false, blacklist = {}}
- msg('Savedvariables are now reset to default')
- elseif(str == 'all') then
- pErrorDB.all = not pErrorDB.all
- msg(format('Filtering all events turned %s', pErrorDB.all and 'on' or 'off'))
+ pErrorDB = {}
+ print('|cffff8080pError:|r Database is now reset to default')
elseif(str == 'list') then
- if(pErrorDB.all) then
- msg('Filtering all events!')
- elseif(not pErrorDB.blacklist[1]) then
- msg('Database is empty')
- else
- msg('Listing database of events:')
-
- for k, v in next, pErrorDB.blacklist do
- msg(format('|cff95ff95 \'%s\'|r', v))
+ if(pErrorDB[1]) then
+ print('|cffff8080pError:|r Listing database:')
+ for _, v in next, pErrorDB do
+ print(' |cff95ff95', v, '|r')
end
+ else
+ print('|cffff8080pError:|r Database is empty')
end
elseif(#str > 0) then
- if(pErrorDB.all) then
- msg('Can\'t add to database, pError is filtering all events')
- else
- for k, v in next, pErrorDB.blacklist do
- if(find(str, v)) then
- tremove(pErrorDB.blacklist, k)
- return msg(format('Removed |cff95ff95\'%s\'|r from the database', v))
- end
+ for k, v in next, pErrorDB do
+ if(find(str, v)) then
+ tremove(pErrorDB, k)
+ return print('|cffff8080pError:|r Removed|cff95ff95', v, '|rfrom database')
end
-
- tinsert(pErrorDB.blacklist, str)
- msg(format('Added |cff95ff95\'%s\'|r to the database', str))
end
- else
- msg('Please provide an error string')
+
+ tinsert(pErrorDB, str)
+ print('|cffff8080pError:|r Added|cff95ff95', str, '|rto database')
end
end
local function onEvent(self, event, str, ...)
- if(event == 'UI_ERROR_MESSAGE') then
- if(pErrorDB.all) then
- return
- elseif(pErrorDB.blacklist[1]) then
- for k, v in next, pErrorDB.blacklist do
- if(find(lower(str), v)) then return end
+ if(event == 'UI_ERROR_MESSAGE' and pErrorDB[1]) then
+ for k, v in next, pErrorDB do
+ if(find(lower(str), v)) then
+ return
end
end
end
@@ -73,18 +53,22 @@ local function onEvent(self, event, str, ...)
return orig(self, event, str, ...)
end
-local function onLoad(self, event, addon)
- if(addon ~= 'pError') then return end
- self:UnregisterEvent(event)
+pError:RegisterEvent('ADDON_LOADED')
+pError:SetScript('OnEvent', function(self, event, name)
+ if(name == 'pError') then
+ self:SetScript('OnEvent', nil)
- pErrorDB = pErrorDB or {all = false, blacklist = {}}
+ if(not pErrorUpdated) then
+ print('|cffff8080pError:|r Converted database into new format, thanks for updating!')
+ pErrorDB = pErrorDB.blacklist
+ pErrorUpdated = true
+ end
- SLASH_pError1 = '/perror'
- SlashCmdList.pError = slashCommand
+ pErrorDB = pErrorDB or {}
- UIErrorsFrame:SetScript('OnEvent', onEvent)
-end
+ SLASH_pError1 = '/perror'
+ SlashCmdList[name] = function(str) slashCommand(lower(str)) end
-local addon = CreateFrame('Frame')
-addon:RegisterEvent('ADDON_LOADED')
-addon:SetScript('OnEvent', onLoad)
\ No newline at end of file
+ UIErrorsFrame:SetScript('OnEvent', onEvent)
+ end
+end)
\ No newline at end of file
diff --git a/pError/pError.toc b/pError/pError.toc
index acac1ec..6eab871 100644
--- a/pError/pError.toc
+++ b/pError/pError.toc
@@ -3,6 +3,6 @@
## Version: 30100.wowi:revision
## Title: |cffff6000p|rError
## Notes: Hide those pesky errors!
-## SavedVariables: pErrorDB
+## SavedVariables: pErrorDB, pErrorUpdated
pError.lua
\ No newline at end of file