Help with displaying cents

I’ve been trying to get my money balance for my game to show a zero at the ends even if its 1.5
Example:
The money I have in storage/Variable is $1.50.
but on my Money Balance text shows $1.5
Any help is appreciated

You can add a zero :slight_smile:
set text to VariableString(money) + “0”
Then, if the zero should only appear at certain times, you will have to figure out when, and add the appropriate conditions.

Check out this thread. I was trying to figure out the same thing, but in reverse to put zeros at the beginning for my score. The solution here worked for me and could help you as well.

1 Like

Do you know any way to reverse this for what I’m trying todo?

It’s not going to be pretty.

You’ll need to:

  1. Store your number as a string variable.
  2. Get the position of the period in your string (StrFindLastFrom(string, string, number))
  3. If the result 2 (meaning your string ends with “.” and then 1 character), add “0” (this means append 0 to the end of hte string)
  4. Otherwise, return the value of the string.

Here’s the expression reference: Expressions reference [GDevelop wiki]