view GoldPrice.lua @ 3:899a07e4bef9

- wakeup packpager.
author Tercioo
date Tue, 26 Jan 2016 10:07:14 -0200
parents 216d8b3d039c
children 4fbf9f182530
line wrap: on
line source
do
	local f = CreateFrame ("frame", "GoldPriceFrame", UIParent)
	f:RegisterEvent ("TOKEN_MARKET_PRICE_UPDATED")
	f:Hide()

	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)
		if (f.canShow) then
			local price = C_WowTokenPublic.GetCurrentMarketPrice()
			price = floor (price / 10000)
			print ("|cFFFF9900Token Price|r: ", f:comma_value (price) .. "|TInterface\\MoneyFrame\\UI-GoldIcon:0:0:2:0|t")
			f.canShow = false
		end
	end)
end

SLASH_GoldPrice1, SLASH_GoldPrice2 = "/gold", "/token"
function SlashCmdList.GoldPrice (msg, editbox)
	if (GoldPriceFrame.LastQuerry and GoldPriceFrame.LastQuerry+15 > GetTime()) then
		local price = C_WowTokenPublic.GetCurrentMarketPrice()
		if (price) then
			price = floor (price / 10000)
			return print ("|cFFFF9900Token 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