comparison GoldPrice.lua @ 0:3b695b187743

First Commit
author Tercio
date Fri, 10 Apr 2015 17:05:17 -0300
parents
children 216d8b3d039c
comparison
equal deleted inserted replaced
-1:000000000000 0:3b695b187743
1
2
3
4 do
5 local f = CreateFrame ("frame", "GoldPriceFrame", UIParent)
6 f:RegisterEvent ("TOKEN_MARKET_PRICE_UPDATED")
7 f:Hide()
8
9 function f:comma_value (n)
10 n = floor (n)
11 local left,num,right = string.match (n,'^([^%d]*%d)(%d*)(.-)$')
12 return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right
13 end
14
15 f:SetScript ("OnEvent", function (self, event)
16
17 local price = C_WowTokenPublic.GetCurrentMarketPrice()
18 price = floor (price / 10000)
19
20 print ("|cFFFF9900Token Price|r: ", f:comma_value (price) .. "|TInterface\\MoneyFrame\\UI-GoldIcon:0:0:2:0|t")
21 end)
22 end
23
24 SLASH_GoldPrice1, SLASH_GoldPrice2 = "/gold", "/token"
25 function SlashCmdList.GoldPrice (msg, editbox)
26 if (GoldPriceFrame.LastQuerry and GoldPriceFrame.LastQuerry+15 > GetTime()) then
27 local price = C_WowTokenPublic.GetCurrentMarketPrice()
28 price = floor (price / 10000)
29 return print ("|cFFFF9900Token Price|r: ", GoldPriceFrame:comma_value (price) .. "|TInterface\\MoneyFrame\\UI-GoldIcon:0:0:2:0|t")
30 end
31 GoldPriceFrame.LastQuerry = GetTime()
32 C_WowTokenPublic.UpdateMarketPrice()
33 end
34
35