diff --git a/BorrowerAndLender.lua b/BorrowerAndLender.lua
index 334bedf..fd20803 100644
--- a/BorrowerAndLender.lua
+++ b/BorrowerAndLender.lua
@@ -1,5 +1,5 @@
BorrowerAndLender = {}
-LibStub("AceTimer-3.0"):Embed(BorrowerAndLender)
+
local LAM = LibStub:GetLibrary("LibAddonMenu-1.0")
local originalLevel
@@ -7,13 +7,9 @@ local inBank
local control = ZO_OptionsWindow.controlTable[2][9]
local currentWait = nil
local settings
-local blacklist = {
- ["Lady Adima^F"] = true,
- ["Count Hosni at-Tura^M"] = true
- }
-function EndsWith(String,End)
+local function EndsWith(String,End)
return End=='' or string.sub(String,-string.len(End))==End
end
@@ -35,23 +31,50 @@ local function WhoAmI(eventCode, options)
end
end
+local function tFindChat(t, entry)
+ for i,v in ipairs(t) do
+ if v.chat == entry then return i end
+ end
+ return nil
+end
+
local function FilterNPC(eventCode, channel, npc, chat)
if channel ~= CHAT_CHANNEL_MONSTER_SAY and channel ~= CHAT_CHANNEL_MONSTER_YELL then return end
- if blacklist[npc] then return end
- if not settings.chats[npc] then settings.chats[npc] = {} end
-
- chat = chat:gsub("\n",""):gsub("\r","")
-
- if not settings.chats[npc][chat] then settings.chats[npc][chat] = 0 return end
-
- settings.chats[npc][chat] = settings.chats[npc][chat] + 1
+ if settings.blacklist[npc] then return end
+ if not settings.chats[npc] then
+ settings.chats[npc] = {}
+ end
+
+ local chatIndex = tFindChat(settings.chats[npc], chat)
+ if not chatIndex then
+ table.insert(settings.chats[npc], {chat = chat, count = 1})
+ return
+ else
+ settings.chats[npc][chatIndex].count = settings.chats[npc][chatIndex].count + 1
+ end
+
if currentWait then BorrowerAndLender:CancelTimer(currentWait) end
currentWait = BorrowerAndLender:ScheduleTimer(SpeakUpLad, (#chat/15) + 2)
Hush()
end
+local function AddToBlackList()
+ local name = GetRawUnitName("reticleover")
+ if name == "" then return end
+ settings.blacklist[name] = true
+ d("Adding " .. name:gsub("%^[%a]+","") .. " to the list of npcs to bypass")
+ EVENT_MANAGER:UnregisterForEvent("BALAdd", EVENT_RETICLE_TARGET_CHANGED)
+end
+
+local function RemoveFromBlackList()
+ local name = GetRawUnitName("reticleover")
+ settings.blacklist[name] = nil
+ d(name:gsub("%^[%a]+", "") .. " will now be processed by the addon")
+ EVENT_MANAGER:UnregisterForEvent("BALRemove", EVENT_RETICLE_TARGET_CHANGED)
+end
+
local function BorrowerAndLenderLoaded(eventCode, addOnName)
if(addOnName ~= "BorrowerAndLender") then
@@ -60,12 +83,13 @@ local function BorrowerAndLenderLoaded(eventCode, addOnName)
local defaults = {
chats = {},
+ blacklist = {},
defaultSoundLevel = control.currentChoice or control.value or 75,
muteBank = true,
muteAmbient = true
}
- settings = ZO_SavedVars:New("BorrowerAndLender_Settings", 3, nil, defaults)
+ settings = ZO_SavedVars:New("BorrowerAndLender_Settings", 6, nil, defaults)
local panel = LAM:CreateControlPanel("BAL", "Borrower And Lender")
@@ -104,6 +128,19 @@ local function BorrowerAndLenderLoaded(eventCode, addOnName)
if settings.muteAmbient then
EVENT_MANAGER:RegisterForEvent("BALChat", EVENT_CHAT_MESSAGE_CHANNEL, FilterNPC)
end
+
+ SLASH_COMMANDS["/baladd"] =
+ function()
+ EVENT_MANAGER:RegisterForEvent("BALAdd", EVENT_RETICLE_TARGET_CHANGED, AddToBlackList)
+ d("Mouse over the NPC you wish to hear all the time")
+ end
+ SLASH_COMMANDS["/balremove"] =
+ function()
+ EVENT_MANAGER:RegisterForEvent("BALRemove", EVENT_RETICLE_TARGET_CHANGED, RemoveFromBlackList)
+ d("Mouse over the NPC you wish to remove from the 'always hear' list.")
+ end
+
+
end
function BorrowerAndLender:CommandHandler()