Adding a zero to small numbers like 0.2

Hello, I am making a money system for a Wild west based game. Since the game will take place in the late 1800’s, change (cents) will be used quite frequently.

However when I use cents, It gives me this weird looking number. (Top most number)
image

I want to add a zero to the .5, so it looks something like 20.50 instead of what it looks like now, Any suggestions on how to do this will be helpful.

Well, Just saying… You could just do just append a zero to it (string. .“0”). However I’m not sure if there’s an actual math function that adds a zero(I have not bothered to fully read all the math functions there are for Lua.

1 Like

As a side note, Nice fonts you got there.

1 Like

You can use string.format("%.2f", yourNumberHere) to format the number to always have 2 decimals.

You could even change the format to "$%.2f" so that you can also add the $ in one go.

3 Likes

Appreciate it, A wild west game I was developing on recently shut down and I plan on carrying out its legacy.

I’ll try this out, it looks promising lol.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.