annotate GoldPrice.lua @ 4:16d869fddc71

- ToC Update.
author Tercio
date Tue, 19 Jul 2016 13:56:11 -0300
parents 899a07e4bef9
children 4fbf9f182530
rev   line source
Tercio@0 1 do
Tercio@0 2 local f = CreateFrame ("frame", "GoldPriceFrame", UIParent)
Tercio@0 3 f:RegisterEvent ("TOKEN_MARKET_PRICE_UPDATED")
Tercio@0 4 f:Hide()
Tercioo@3 5
Tercio@0 6 function f:comma_value (n)
Tercio@0 7 n = floor (n)
Tercio@0 8 local left,num,right = string.match (n,'^([^%d]*%d)(%d*)(.-)$')
Tercio@0 9 return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right
Tercio@0 10 end
Tercio@0 11
Tercio@0 12 f:SetScript ("OnEvent", function (self, event)
Tercioo@2 13 if (f.canShow) then
Tercioo@2 14 local price = C_WowTokenPublic.GetCurrentMarketPrice()
Tercioo@2 15 price = floor (price / 10000)
Tercioo@2 16 print ("|cFFFF9900Token Price|r: ", f:comma_value (price) .. "|TInterface\\MoneyFrame\\UI-GoldIcon:0:0:2:0|t")
Tercioo@2 17 f.canShow = false
Tercioo@2 18 end
Tercio@0 19 end)
Tercio@0 20 end
Tercio@0 21
Tercio@0 22 SLASH_GoldPrice1, SLASH_GoldPrice2 = "/gold", "/token"
Tercio@0 23 function SlashCmdList.GoldPrice (msg, editbox)
Tercio@0 24 if (GoldPriceFrame.LastQuerry and GoldPriceFrame.LastQuerry+15 > GetTime()) then
Tercio@0 25 local price = C_WowTokenPublic.GetCurrentMarketPrice()
Tercioo@2 26 if (price) then
Tercioo@2 27 price = floor (price / 10000)
Tercioo@2 28 return print ("|cFFFF9900Token Price|r: ", GoldPriceFrame:comma_value (price) .. "|TInterface\\MoneyFrame\\UI-GoldIcon:0:0:2:0|t")
Tercioo@2 29 end
Tercio@0 30 end
Tercioo@2 31
Tercioo@2 32 GoldPriceFrame.canShow = true
Tercio@0 33 GoldPriceFrame.LastQuerry = GetTime()
Tercio@0 34 C_WowTokenPublic.UpdateMarketPrice()
Tercioo@2 35 end