Hello, I’m currently trying to write code so that it will auto-create commas for different stats regarding money. I am not a coder and I am currently learning while doing so however I keep coming across a problem with the current code I have written which I found help on in a different topic tread. I put the code for commas into a different file currently as money_calculations.txt:
*temp current_char 0
*temp char_count 1
*temp length 0
*temp comma_check 0
*set display_wealth ""
*set length length(wealth)
*set current_char length
*label start_wealth_loop
*if current_char > 0
*set comma_check (char_count - 1) modulo 3
*if ((comma_check = 0) and (current_char != length))
*set display_wealth "," & display_wealth
*set display_wealth (wealth#{current_char}) & display_wealth
*set current_char - 1
*set char_count + 1
*goto start_wealth_loop
*return
However while this does work, specify for wealth, when I try to do it with a different variable for income which here is the code for it:
*temp current_char 0
*temp char_count 1
*temp length 0
*temp comma_check 0
*set display_wealth ""
*set length length(wealth)
*set current_char length
*label start_wealth_loop
*if current_char > 0
*set comma_check (char_count - 1) modulo 3
*if ((comma_check = 0) and (current_char != length))
*set display_wealth "," & display_wealth
*set display_wealth (wealth#{current_char}) & display_wealth
*set current_char - 1
*set char_count + 1
*goto start_wealth_loop
*return
*set display_income ""
*set length length(income)
*set current_char length
*label start_income_loop
*if current_char > 0
*set comma_check (char_count - 1) modulo 3
*if ((comma_check = 0) and (current_char != length))
*set display_income "," & display_income
*set display_income (income#{current_char}) & display_income
*set current_char - 1
*set char_count + 1
*goto start_income_loop
*return
It doesn’t display the income value correctly when going to the stats page, it just shows as:
James Lee Smith
Age: 40
Wealth: $2,000
Income: $
Here is the current code in my choicescript_stats.txt file if it provides any help:
[b]$!{firstname} $!{middlename} $!{lastname}[/b]
*line_break
[b]Age:[/b] ${age}
*line_break
*gosub_scene money_calculations
[b]Wealth:[/b] $${display_wealth}
*line_break
*gosub_scene money_calculations
[b]Income:[/b] $${display_income}