Limiting attribute value printed to screen?

CheeseMyBaby
08 May 2018, 16:12

Long story short.
I'm writing a guy in the army. Everything he's carrying has a weight (displayed as "Carrying ! kilo").
I went a bit overboard with the whole thing and now every time he fires his pistol his total weight drop approx 0.01 kilo.
Everything is working but if I empty the gun, reload it from the box of ammo I'm carrying and repeat the process; if I decide to "drop ammo" this gets displayed:

CARRYING: 0.950000000000001 KG

I know this whole thing might be a bit overkill and all but I sort of like it.
However... I'd like for the status to show

CARRYING: 0.95 KG

So... the question: Is there a way to make the game print only the first 2 digits after the . ?


K.V.
08 May 2018, 16:35
object.weight =  Round(object.weight, 2)

K.V.
08 May 2018, 16:40

PS

If you'd like to make your parser understand profanity, message me!


CheeseMyBaby
08 May 2018, 17:06

object.weight = Round(object.weight, 2)

That was simple enough. Thanks a lot!
Only one question....
Where do I... you know... actually put that code?


CheeseMyBaby
08 May 2018, 17:19

And, of course, I've sent you a message regarding that other thing :)


K.V.
08 May 2018, 17:32

I'd probably that to script when firing the pistol.

pistol.weight =  Round(object.weight, 2)

K.V.
08 May 2018, 17:42

...or wherever you decrease the weight.


CheeseMyBaby
08 May 2018, 17:44

Ah, of course. I'll blame it on the fever =)
Thanks K.V.!


K.V.
08 May 2018, 17:50

Fevers suck. (They make me do dumb stuff (or dumber-than-usual stuff).)