Tercio@0: do Tercio@0: local f = CreateFrame ("frame", "GoldPriceFrame", UIParent) Tercio@0: f:RegisterEvent ("TOKEN_MARKET_PRICE_UPDATED") Tercio@6: f:RegisterEvent ("ADDON_LOADED") Tercio@0: f:Hide() Tercio@6: Tercio@6: local addonName = ... Tercioo@3: Tercio@0: function f:comma_value (n) Tercio@0: n = floor (n) Tercio@0: local left,num,right = string.match (n,'^([^%d]*%d)(%d*)(.-)$') Tercio@0: return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right Tercio@0: end Tercio@0: Tercio@6: f:SetScript ("OnEvent", function (self, event, ...) Tercio@6: --GoldPriceGlobalSV Tercio@6: if (event == "TOKEN_MARKET_PRICE_UPDATED") then Tercio@6: if (f.canShow) then Tercio@6: local price = C_WowTokenPublic.GetCurrentMarketPrice() Tercio@6: price = floor (price / 10000) Tercio@6: print ("|c66FFDDDDToken Price|r: ", f:comma_value (price) .. "|TInterface\\MoneyFrame\\UI-GoldIcon:0:0:2:0|t") Tercio@6: f.canShow = false Tercio@6: end Tercio@6: end Tercio@6: if (... == addonName) then Tercio@6: GoldPriceGlobalSV = GoldPriceGlobalSV or {} Tercio@6: if (GoldPriceGlobalSV.ShowOnLogin == nil) then Tercio@6: GoldPriceGlobalSV.ShowOnLogin = true Tercio@6: end Tercio@6: Tercio@6: if (GoldPriceGlobalSV.ShowOnLogin) then Tercio@6: f.ShowGoldPrice() Tercio@6: end Tercioo@2: end Tercio@0: end) Tercio@6: Tercio@6: function f.ShowGoldPrice() Tercio@6: if (GoldPriceFrame.LastQuerry and GoldPriceFrame.LastQuerry+15 > GetTime()) then Tercio@6: local price = C_WowTokenPublic.GetCurrentMarketPrice() Tercio@6: if (price) then Tercio@6: price = floor (price / 10000) Tercio@6: return print ("|c66FFDDDDToken Price|r: ", GoldPriceFrame:comma_value (price) .. "|TInterface\\MoneyFrame\\UI-GoldIcon:0:0:2:0|t") Tercio@6: end Tercio@6: end Tercio@6: Tercio@6: GoldPriceFrame.canShow = true Tercio@6: GoldPriceFrame.LastQuerry = GetTime() Tercio@6: C_WowTokenPublic.UpdateMarketPrice() Tercio@6: end Tercio@6: Tercio@0: end Tercio@0: Tercio@0: SLASH_GoldPrice1, SLASH_GoldPrice2 = "/gold", "/token" Tercio@6: function SlashCmdList.GoldPrice (msg, editbox) Tercio@6: print ("|cFFFF9900Token Price Commands") Tercio@6: print ("|cFFFF9900/token onlogin|r: disable showing the token price on login.") Tercio@6: Tercio@6: if (msg == "onlogin") then Tercio@6: GoldPriceGlobalSV.ShowOnLogin = not GoldPriceGlobalSV.ShowOnLogin Tercio@6: print ("|c66FFDDDDToken Price|r show on login:", GoldPriceGlobalSV.ShowOnLogin) Tercio@6: return Tercio@0: end Tercio@6: Tercio@6: GoldPriceFrame.ShowGoldPrice() Tercioo@2: end