comparison GoldPrice.lua @ 2:216d8b3d039c

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