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