From 7a86591798a1e643c97182b4b92edc922f9544a0 Mon Sep 17 00:00:00 2001 From: Boneshock Date: Tue, 17 Dec 2024 13:14:18 +0100 Subject: [PATCH] Currency Trigger: Add Player Money --- WeakAuras/Prototypes.lua | 117 ++++++++++++++++++++++++++++++++++++++- WeakAuras/Types.lua | 5 +- 2 files changed, 120 insertions(+), 2 deletions(-) diff --git a/WeakAuras/Prototypes.lua b/WeakAuras/Prototypes.lua index ae8c07e455..d6824aef91 100644 --- a/WeakAuras/Prototypes.lua +++ b/WeakAuras/Prototypes.lua @@ -11279,6 +11279,7 @@ Private.event_prototypes = { local events = { "CHAT_MSG_CURRENCY", "CURRENCY_DISPLAY_UPDATE", + "PLAYER_MONEY", } if WeakAuras.IsRetail() then tinsert(events, "ACCOUNT_CHARACTER_CURRENCY_DATA_RECEIVED") @@ -11290,6 +11291,55 @@ Private.event_prototypes = { force_events = "WA_DELAYED_PLAYER_ENTERING_WORLD", name = WeakAuras.newFeatureString..L["Currency"], triggerFunction = function(trigger) + if trigger.currencyId == "money" then + local moneyChecks = {} + local function createMoneyCheck(property, operator, value, use) + if not use then return nil end + return([[ + if not (%s %s %s) then + active = false + end + ]]):format(property, operator or "<", tonumber(value) or 0) + end + + table.insert(moneyChecks, createMoneyCheck("gold", trigger.gold_operator, trigger.gold, trigger.use_gold)) + table.insert(moneyChecks, createMoneyCheck("silver", trigger.silver_operator, trigger.silver, trigger.use_silver)) + table.insert(moneyChecks, createMoneyCheck("copper", trigger.copper_operator, trigger.copper, trigger.use_copper)) + + local moneyCheckString = table.concat(moneyChecks, "\n") + + local ret = [=[return + function(states) + local money = GetMoney() + local gold = floor(money / 1e4) + local silver = floor(money / 100 %% 100) + local copper = money %% 100 + local active = true + + -- Insert Gold/Silver/Copper checks + %s + + states[""] = states[""] or {} + local state = states[""] + state.name = MONEY + state.icon = C_CurrencyInfo.GetCoinIcon(money) + state.progressType = "static" + state.show = active + state.changed = state.value ~= money + + state.value = money + state.money = money + state.gold = gold + state.silver = silver + state.copper = copper + + return state.changed + end + ]=] + + return ret:format(moneyCheckString) + end + local quantityChecks, tristateChecks, cloneChecks = {}, {}, {} local function createQuantityCheck(property, operator, value, primary, use) @@ -11499,6 +11549,9 @@ Private.event_prototypes = { display = L["Quantity"], store = true, conditionType = "number", + enable = function(trigger) + return trigger.currencyId ~= "money" + end }, { name = "total", @@ -11513,6 +11566,47 @@ Private.event_prototypes = { hidden = true, test = "true", }, + { + name = "money", + type = "number", + display = L["Player Money"], + store = true, + hidden = true, + test = "true", + enable = function(trigger) + return trigger.currencyId == "money" + end + }, + { + name = "gold", + type = "number", + display = Private.coin_icons.gold .. L["Gold"], + store = true, + conditionType = "number", + enable = function(trigger) + return trigger.currencyId == "money" + end + }, + { + name = "silver", + type = "number", + display = Private.coin_icons.silver .. L["Silver"], + store = true, + conditionType = "number", + enable = function(trigger) + return trigger.currencyId == "money" + end + }, + { + name = "copper", + type = "number", + display = Private.coin_icons.copper .. L["Copper"], + store = true, + conditionType = "number", + enable = function(trigger) + return trigger.currencyId == "money" + end + }, { name = "realCharacterQuantity", type = "number", @@ -11622,6 +11716,9 @@ Private.event_prototypes = { store = true, hidden = true, test = "true", + enable = function(trigger) + return trigger.currencyId ~= "money" + end }, { name = "quality", @@ -11629,7 +11726,10 @@ Private.event_prototypes = { display = L["Quality Id"], hidden = true, test = "true", - store = true + store = true, + enable = function(trigger) + return trigger.currencyId ~= "money" + end }, { name = "discovered", @@ -11637,6 +11737,9 @@ Private.event_prototypes = { display = L["Discovered"], store = true, conditionType = "bool", + enable = function(trigger) + return trigger.currencyId ~= "money" + end }, { name = "transferPercentage", @@ -11646,6 +11749,9 @@ Private.event_prototypes = { conditionType = "number", hidden = true, test = "true", + enable = function(trigger) + return trigger.currencyId ~= "money" + end }, { name = "characterName", @@ -11654,6 +11760,9 @@ Private.event_prototypes = { store = true, hidden = true, test = "true", + enable = function(trigger) + return trigger.currencyId ~= "money" + end }, { name = "characterGUID", @@ -11662,6 +11771,9 @@ Private.event_prototypes = { store = true, hidden = true, test = "true", + enable = function(trigger) + return trigger.currencyId ~= "money" + end }, { name = "mainCharacter", @@ -11671,6 +11783,9 @@ Private.event_prototypes = { conditionType = "bool", hidden = true, test = "true", + enable = function(trigger) + return trigger.currencyId ~= "money" + end }, { name = "clones", diff --git a/WeakAuras/Types.lua b/WeakAuras/Types.lua index dea69d2c4d..c1721b9e79 100644 --- a/WeakAuras/Types.lua +++ b/WeakAuras/Types.lua @@ -1692,7 +1692,10 @@ local function InitializeCurrencies() end Private.discovered_currencies["member"] = "|Tinterface\\common\\ui-searchbox-icon:0:0:0:-2|t"..L["Specific Currency"]; - Private.discovered_currencies_sorted["member"] = -1; + Private.discovered_currencies_sorted["member"] = -2; + + Private.discovered_currencies["money"] = "|Tinterface/moneyframe/ui-goldicon:0:0:0:-2|t"..L["Player Money"]; + Private.discovered_currencies_sorted["money"] = -1; end ---@type function