Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local warningSound = true
- minToWarn = 1
- defaultThreshold = 3000
- defaultTracking = true
- --[[ CurrencyMonitor (Description currently inaccurate)
- This program watches a player's justice points, valor points, conquest points, and honor points
- and flashes a raid warning and optional raid warning sound when any of them exceeds a predetermined
- threshold. CurrencyMonitor is meant to be super simple and configurable only from within this file,
- meaning you won't find any slash commands or in-game configuration (yet).
- Line 1 holds the threshold at which you want CurrencyMonitor to alert you; simply change the value
- on line 1 to your desired threshold. After gaining a currency, for example Justice Points, if you
- have more than your threshold, this add-on will alert you with a raid warning. If you want the raid
- warning sound, simply change line 3 to true.
- The variable minToWarn (line 2) represents the individual amount for which CM will warn the
- user. For example, by default honorable kills worth 7 honor will not fire the warning because
- they are less than 50 (the default value for minToWarn). If you set minToWarn to zero, every
- honor gain while over your threshold, even 1 point, will spam you. Find a happy medium with this
- number.
- *** CurrencyMonitor is Copyright 2011 by Phael of Hydraxis ***
- Please do not distribute altered copies of this add-on because it can make maintaining it a
- nightmare. If you want to see a feature built into it, please add a comment on the official
- download pages on curse.com and wowinterface.com.
- For now, I will take bug reports and feature requests directly in the comments sections of the
- official release channels. Until such a time that I believe I need a ticket tracking system (which
- hopefully never happens), I will simply answer bug reports/feature requests in comments sections.
- ---------------
- Version History
- ---------------
- -- DATE -- - V.2.0 Created the first in-game GUI. Bugs likely. Added slash command to hide or
- show the GUI.
- 07/02/2012 - V.1.2.3 Removed an unnecessary registered event. Matched default values to
- description. Flipped the change log. Moved variables around in the file to
- make maintaining it just a bit easier.
- 02/24/2012 - V.1.2.2 Fixed a problem with the currency warning not updating to reflect the
- current amount of points when points are awarded. Minor .toc file fix.
- 12/15/2011 - V.1.2.1 Changed some variables to local to avoid polluting the global environment.
- 12/09/2011 - V.1.2 Spam bug fix. Also warns of only the type of currency that triggered the
- warning. Considerable code rewrite for less redundancy.
- 12/05/2011 - V.1.1 Removed BG spamminess through smart points announcement.
- 12/02/2011 - V.1.0 Now firing on the correct event.
- 12/02/2011 - V.0.1(BETA) (Initial release)
- -----
- To-Do
- -----
- Nap. Damn I love naps.
- --- Credits ---
- Credit goes to Wowhead user eidyia for the idea and additional input that helped hone this add-on's
- functionality. Specifically, thank eidyia for the version 1.1 removal of BG spam and the 1.2 removal
- of buggy spam!
- --]]
- ----------------- Know what you're doing before you edit anything below this line. -----------------
- -- Add slash command configuration menu
- SLASH_CURRENCYMONITOR1, SLASH_CURRENCYMONITOR2 = "/cm", "/currencymonitor";
- function SlashCmdList.CURRENCYMONITOR(msg, editbox)
- CM_ToggleGUI()
- print(type(CM_db))
- end
- -- Table to reference to determine if a currency is tracked
- local trackingTable = {}
- -- Table to store currency IDs for querying the server
- local currencies = {
- "395", -- Justice points
- "396", -- Valor points
- "392", -- Honor points
- "390" -- Conquest points
- }
- -- Table to store currency names for display to the player
- local allCurrency = {
- "Justice Points",
- "Valor Points",
- "Honor Points",
- "Conquest Points"
- }
- -- Table to store currency thresholds over which the player should be notified
- local currencyThresholds = {}
- -- An empty table that gets used more often than a $5 whore
- local currentAmount = {}
- -- Register the event our invisible frame cares about and set up the GUI
- function CurrencyMonitor_OnLoad()
- CurrencyMonitorFrame:RegisterEvent("CHAT_MSG_CURRENCY")
- CurrencyMonitorFrame:RegisterEvent("ADDON_LOADED")
- end
- -- Update whether or not the currency is marked for tracking
- function CM_updateChecked(self, i)
- if self:GetChecked() then
- trackingTable[i] = true
- else
- trackingTable[i] = false
- end
- -- Debugging information
- print("Item "..i.." is now "..tostring(trackingTable[i])..".")
- print(type(CM_db))
- end
- -- Update all thresholds with edit box values when the Accept button is pressed
- function CM_UpdateAll(v,j,c,h)
- currencyThresholds = {v:GetText(), j:GetText(), c:GetText(), h:GetText()}
- CM_db["valor"] = {
- ["threshold"] = currencyThresholds[1],
- ["tracked"] = trackingTable[1]
- }
- CM_db["justice"] = {
- ["threshold"] = currencyThresholds[2],
- ["tracked"] = trackingTable[2]
- }
- CM_db["conquest"] = {
- ["threshold"] = currencyThresholds[3],
- ["tracked"] = trackingTable[3]
- }
- CM_db["honor"] = {
- ["threshold"] = currencyThresholds[4],
- ["tracked"] = trackingTable[4]
- }
- for k, v in pairs(CM_db) do
- print(v.threshold, v.tracked)
- end
- CM_ToggleGUI()
- end
- -- Loop through and get the current amount of the four currencies we care about
- local function getAllCurrencies()
- for i = 1, 4 do
- local _, amountNow = GetCurrencyInfo(currencies[i])
- table.insert(currentAmount, amountNow)
- end
- end
- -- Adds the warning message to the raid warning frame
- local function printOutput(triggerCurrency)
- for i = 1, 4 do
- if allCurrency[i] == triggerCurrency then
- if warningSound then
- PlaySoundFile("Sound\\Interface\\RaidWarning.wav")
- end
- RaidNotice_AddMessage(RaidWarningFrame, "You have " .. currentAmount[i] .. " " .. allCurrency[i] .. "!", ChatTypeInfo["RAID_WARNING"])
- end
- end
- end
- -- The functions to run when our registered events fire
- function CurrencyMonitor_OnEvent(self, event, arg1)
- if event == "CHAT_MESSAGE_CURRENCY" and tonumber(string.match(arg1, '%d+', -4)) >= minToWarn then
- getAllCurrencies()
- for i = 1, 4 do
- local triggerCurrency = string.match(arg1, allCurrency[i])
- if (currentAmount[i] >= currencyThresholds[i]) and (trackingTable[i]) then
- printOutput(triggerCurrency)
- end
- end
- -- Empty the working tables for next use
- currentAmount = nil
- currentAmount = {}
- end
- if (event == "ADDON_LOADED" and arg1 == "CurrencyMonitor") then
- -- If there isn't a table already in the saved variables from last session, create one
- if not (CM_db) then
- CM_db = {}
- -- Assign default values to the new table
- CM_db["valor"] = {["threshold"] = defaultThreshold, ["tracked"] = defaultTracking}
- CM_db["justice"] = {["threshold"] = defaultThreshold, ["tracked"] = defaultTracking}
- CM_db["conquest"] = {["threshold"] = defaultThreshold, ["tracked"] = defaultTracking}
- CM_db["honor"] = {["threshold"] = defaultThreshold, ["tracked"] = defaultTracking}
- end
- print(type(CM_db))
- -- Set the edit boxes' default values
- CM_ValorEdit:SetText(CM_db["valor"].threshold)
- CM_JusticeEdit:SetText(CM_db["justice"].threshold)
- CM_ConquestEdit:SetText(CM_db["conquest"].threshold)
- CM_HonorEdit:SetText(CM_db["honor"].threshold)
- end
- end
- -- Hide the GUI if it's shown, or show it if it's hidden
- function CM_ToggleGUI(self)
- if CurrencyMonitorFrame:IsVisible(self) then
- CurrencyMonitorFrame:Hide(self)
- else
- CurrencyMonitorFrame:Show(self)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement