Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Jedzkie |
Can someone help me fix this code? The issue is the comma in digits.
efunc comma(number):
var string = str(number)
var mod = string.length() % 3
var res = ""
for i in range(0, string.length()):
if i != 0 && i % 3 == mod:
res += ","
res += string[i]
return res
pass
func money_suffix(money):
var suffix = [" ", “k”, “m”, “b”, “t”]
var x = 0
while money >= 1000:
money /= 1000
x += 1
if x == suffix.size() - 1:
break
var suffixed_money = str(money) + suffix
return suffixed_money
pass
func _process(delta):
MoneyLabel.text = “$” + str(comma(money_suffix(money)))