GetCoinTextureString

From Warcraft Wiki
Jump to navigation Jump to search

Breaks up an amount of money into gold/silver/copper with icons.

formattedAmount = GetCoinTextureString(amount [, fontHeight])

Arguments

amount
number - the amount of money in copper (for example, the return value from GetMoney)
fontHeight
number? - the height of the coin icon; if not specified, defaults to 14.

Returns

formattedAmount
string - a string suitable for printing or displaying.

Example

local money = GetMoney()
local gold = floor(money / 1e4)
local silver = floor(money / 100 % 100)
local copper = money % 100
print(("You have %dg %ds %dc"):format(gold, silver, copper))
-- You have 10851g 62s 40c


print(GetCoinText(GetMoney()))    -- "10851 Gold, 62 Silver, 40 Copper"
print(GetCoinText(12345678, " ")) -- "1234 Gold 23 Silver 45 Copper"
print(GetCoinText(12345678, "X")) -- "1234 GoldX23 SilverX45 Copper"


print(GetMoneyString(12345678))
print(GetMoneyString(12345678, true))
1234g 56s 78c
1,234g 56s 78c


print(GetCoinTextureString(1234578))
print(GetCoinTextureString(1234578, 24))
1234g 56s 78c
1234Gold.png 56Silver.png 78Copper.png