ID:168793
 
How do I get a stat panel to display something like "$1.00" instead of "$1"?

This is for my 8k so I'd prefer there wasn't a 500-line code to do it with, but if its kinda short I probably have extra room :)
Couldn't you use an if statment of some sort so if is was rounded it would show something like:
stat("Money","[money](if statment goes here).00")

Or something along those lines?
In response to Popisfizzy
well I might have values like 1.39 or 55.21 :P

EDIT: how about...

var/X = "[src.money]"
if(src.money%100==0)
X += "00"
else if(src.money %10 == 0)
X += "0"
stat("Money:","[X]")


I'll try that maybe yay
In response to Cowdude
thats what the if() would be for. If there would be numbers on the end, don't show .00.
In response to Popisfizzy
    if(round(src.money*10)/10 == src.money)
if(src.money == round(src.money))
X += ".0"
X += "0"
else if(round(src.money*100)/100 == src.money)
X += ""
stat("Money:","[X]")


that's what I needed. :)
In response to Cowdude
Was what I said useful then?
This is for my 8k so I'd prefer there wasn't a 500-line code to do it with, but if its kinda short I probably have extra room :)

proc/num2currency(num)
var/neg = 0
neg = num < 0
num = abs(num)
. = ""
var/frac = copytext("[num - round(num)]",3)
world.log << frac
switch(length(frac))
if(0)
frac = "00"
if(1)
frac += "0"
else
frac = copytext(frac,1,3)

while(num)
. = ",[num%1000]" + .
num = round(num/1000)
if(length(.))
. = copytext(.,2)
if(neg) . = "-" + .
. = "$" + .
. += ".[frac]"


Kinda large but you could probably shave off some bytes shrinking the labels and removing whitespace :P.
In response to Theodis
len! that's what I needed! x_x oh well mine's shorter than yours :P

EDIT: (I didn't see Fizzy reply :P)

I didn't understand what you meant by if :D I figured it out myself :)