How about

Code:

local repairCost = x
repairCost = repairCost - discounts
print(format("%dG %2dS %2dC",
repairCost/COPPER_PER_GOLD,
math.mod(repairCost/COPPER_PER_SILVER, 100),
math.mod(repairCost, 100)))

setting repairCost to 1234567.5444444 (123G, 45S, and 67.5444444 copper) outputs

"123G 45S 67C"

edit:: guess i will step through the code.

assuming repairCost is 1234567.5444444 and discounts is 0.

format("%dG %02dS %02dC" ...

-Basically, for every tag you have in your format string, you need to put a variable in the following parameters. so for every %d, it expects one parameter that can evaluate to an integer. Because I have 3 %d's, then I have 3 parameters following that string. The %02d tells the format command that the maximum amount of digits is 2. The 0 tells the command that if the amount of digits is less than 2, then pad the number with 0s. simply replace the %02d with %2d if you do not want to pad the numbers with a 0.

repairCost/COPPER_PER_GOLD

-1234567.544444 / 10000 = 123.4567544444

math.mod(repairCost/COPPER_PER_SILVER, 100),

-1234567.544444 / 100 = 12345.675444444

-12345.675444444 % 100 = 45.675444444 (modulos is the remainder. so 100 can go into 12345, 123 times equally with a remainder of 45. another example might be 5 % 3 = 2. saying that 3 can be divided into 5 only once equally, and has a remainder of 2.)

math.mod(repairCost, 100)

- same as above...

-1234567.544444 % 100 is 67.544444 because the remainder of 1234567.544444/100 is 67.544444.

And remember that %d asks for a integer, so it drops the decimal automatically.