Ren'Py Trying to show 1 decimal only [SOLVED]

AdventAnyx

Active Member
Game Developer
Feb 2, 2020
729
2,755
Heya, guys. A quick question from a complete noob.

I'm having a textbutton like this:

Code:
textbutton "Cum total = "+str(float(g_cumin*0.001))+" L":
    blah-blah-blah
Basically I want to quickly convert milliliters to liters, but I only need to show like 1 decimal point. How do I tell RenPy that?

A little bit of explanation:
"g_cumin" is a variable that gathers numbers from different events. I already wrote those events and don't want to re-adjust numbers, they are in milliliters.
I just don't know language at all (not a programmer, just poking around)
 

the66

beware, the germans are cumming
Modder
Donor
Respected User
Jan 27, 2017
7,667
23,783
Heya, guys. A quick question from a complete noob.

I'm having a textbutton like this:

Code:
textbutton "Cum total = "+str(float(g_cumin*0.001))+" L":
    blah-blah-blah
Basically I want to quickly convert milliliters to liters, but I only need to show like 1 decimal point. How do I tell RenPy that?

A little bit of explanation:
"g_cumin" is a variable that gathers numbers from different events. I already wrote those events and don't want to re-adjust numbers, they are in milliliters.
I just don't know language at all (not a programmer, just poking around)
Python:
textbutton "Cum total = {:.1f} L".format(g_cumin/1000.0):
    blah-blah-blah
make sure to use 1000.0 to get a float.
 
  • Like
Reactions: AdventAnyx

AdventAnyx

Active Member
Game Developer
Feb 2, 2020
729
2,755
Python:
textbutton "Cum total = {:.1f} L".format(g_cumin/1000.0):
    blah-blah-blah
make sure to use 1000.0 to get a float.
Oh, wow. I spent an hour trying to figure it out myself and wasn't even close.
Thank you!
:love: