From 4435437aea3eb465e4f17eff536bedc04d399271 Mon Sep 17 00:00:00 2001 From: Jesse Manelius Date: Fri, 9 Mar 2018 18:55:19 +0200 Subject: [PATCH] add level option for .allkeys (eg. .allkeys 15 will only paste keys at or above 15) --- iKeystones.lua | 47 +++++++++++++++++++++++++++++------------------ iKeystones.toc | 2 +- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/iKeystones.lua b/iKeystones.lua index f1490bf..52c2515 100644 --- a/iKeystones.lua +++ b/iKeystones.lua @@ -365,9 +365,10 @@ function iKS:printKeystones() print(str) end end -function iKS:PasteKeysToChat(all,channel) +function iKS:PasteKeysToChat(all,channel, level) if all then -- All keys for this faction local i = 0 + local totalCounter = 0 local str = '' local faction = UnitFactionGroup('player') local msgs = {} @@ -378,20 +379,29 @@ function iKS:PasteKeysToChat(all,channel) i = 0 end if data.faction == faction then - if i > 0 then - str = str .. ' - ' + if not level or (level and data.key.level and data.key.level >= level) then + if i > 0 then + str = str .. ' - ' + end + local itemLink = '' + if data.key.map then + itemLink = string.format('%s (%s)', iKS:getZoneInfo(data.key.map), data.key.level) + else + itemLink = UNKNOWN + end + str = str..string.format('%s: %s', data.name, itemLink) + i = i + 1 + totalCounter = totalCounter + 1 end - local itemLink = '' - if data.key.map then - itemLink = string.format('%s (%s)', iKS:getZoneInfo(data.key.map), data.key.level) - else - itemLink = UNKNOWN - end - str = str..string.format('%s: %s', data.name, itemLink) - i = i + 1 end end - SendChatMessage(str, channel) + if totalCounter > 0 then + if i > 0 then + SendChatMessage(str, channel) + end + elseif level then + SendChatMessage("No keystones at or above " .. level..".", channel) + end else -- Only this char local data = iKeystonesDB[player] if data then @@ -486,12 +496,13 @@ function addon:QUEST_LOG_UPDATE() end end local function ChatHandling(msg, channel) - if msg and (string.lower(msg) == '.allkeys' or string.lower(msg) == '.keys') then - if string.lower(msg) == '.allkeys' then - iKS:PasteKeysToChat(true,channel) - else - iKS:PasteKeysToChat(false,channel) - end + if not msg then return end -- not sure if this can even happen, maybe? + msg = msg:lower() + if msg == '.keys' then + iKS:PasteKeysToChat(false,channel) + elseif msg:find('^.allkeys') then + local level = msg:match('^.allkeys (%d*)') + iKS:PasteKeysToChat(true,channel,tonumber(level)) end end function addon:CHAT_MSG_GUILD(msg) diff --git a/iKeystones.toc b/iKeystones.toc index afd7375..137da07 100644 --- a/iKeystones.toc +++ b/iKeystones.toc @@ -2,7 +2,7 @@ ## Title: iKeystones ## Notes: Tracks your keystones ## Author: Ironi -## Version: 1.561 +## Version: 1.562 ## DefaultState: enabled ## SavedVariables: iKeystonesDB, iKeystonesConfig -- 1.7.9.5