Mercurial > wow > token-price
view GoldPrice.lua @ 17:4838d25bf89c tip
Added tag v8.2.0.016 for changeset 976923a9da65
author | Tercioo |
---|---|
date | Fri, 28 Jun 2019 20:05:08 -0300 |
parents | 4fbf9f182530 |
children |
line wrap: on
line source
do local f = CreateFrame ("frame", "GoldPriceFrame", UIParent) f:RegisterEvent ("TOKEN_MARKET_PRICE_UPDATED") f:RegisterEvent ("ADDON_LOADED") f:Hide() local addonName = ... function f:comma_value (n) n = floor (n) local left,num,right = string.match (n,'^([^%d]*%d)(%d*)(.-)$') return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right end f:SetScript ("OnEvent", function (self, event, ...) --GoldPriceGlobalSV if (event == "TOKEN_MARKET_PRICE_UPDATED") then if (f.canShow) then local price = C_WowTokenPublic.GetCurrentMarketPrice() price = floor (price / 10000) print ("|c66FFDDDDToken Price|r: ", f:comma_value (price) .. "|TInterface\\MoneyFrame\\UI-GoldIcon:0:0:2:0|t") f.canShow = false end end if (... == addonName) then GoldPriceGlobalSV = GoldPriceGlobalSV or {} if (GoldPriceGlobalSV.ShowOnLogin == nil) then GoldPriceGlobalSV.ShowOnLogin = true end if (GoldPriceGlobalSV.ShowOnLogin) then f.ShowGoldPrice() end end end) function f.ShowGoldPrice() if (GoldPriceFrame.LastQuerry and GoldPriceFrame.LastQuerry+15 > GetTime()) then local price = C_WowTokenPublic.GetCurrentMarketPrice() if (price) then price = floor (price / 10000) return print ("|c66FFDDDDToken Price|r: ", GoldPriceFrame:comma_value (price) .. "|TInterface\\MoneyFrame\\UI-GoldIcon:0:0:2:0|t") end end GoldPriceFrame.canShow = true GoldPriceFrame.LastQuerry = GetTime() C_WowTokenPublic.UpdateMarketPrice() end end SLASH_GoldPrice1, SLASH_GoldPrice2 = "/gold", "/token" function SlashCmdList.GoldPrice (msg, editbox) print ("|cFFFF9900Token Price Commands") print ("|cFFFF9900/token onlogin|r: disable showing the token price on login.") if (msg == "onlogin") then GoldPriceGlobalSV.ShowOnLogin = not GoldPriceGlobalSV.ShowOnLogin print ("|c66FFDDDDToken Price|r show on login:", GoldPriceGlobalSV.ShowOnLogin) return end GoldPriceFrame.ShowGoldPrice() end