Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Slasher on Thu 15/09/2022 18:30:30

Title: SOLVED Adding up ints on label
Post by: Slasher on Thu 15/09/2022 18:30:30
Would someone please remind me of adding up ints and show on one label (total from 4 ints).

Code (ags) Select
LMoney.Text=String.Format("%d",Willis_Bank,  Meyers_Bank,  Mercer_Bank,  Guthrie_Bank);

Cheers

EDIT Think I'v done it...
Code (ags) Select
LMoney.Text=String.Format("%d",Willis_Bank +  Meyers_Bank +  Mercer_Bank +  Guthrie_Bank);


Title: Re: SOLVED Adding up ints on label
Post by: Crimson Wizard on Thu 15/09/2022 19:30:42
Do you need to display four ints one by one or display a sum of 4 ints?
Title: Re: SOLVED Adding up ints on label
Post by: Slasher on Thu 15/09/2022 19:48:39
Quote from: Crimson Wizard on Thu 15/09/2022 19:30:42
Do you need to display four ints one by one or display a sum of 4 ints?

Each int gets displayed on it's own Label one by one. The main label displays them as the occur and adds them up on the fly.
Title: Re: SOLVED Adding up ints on label
Post by: Crimson Wizard on Thu 15/09/2022 20:50:48
Quote from: Slasher on Thu 15/09/2022 19:48:39
Each int gets displayed on it's own Label one by one. The main label displays them as the occur and adds them up on the fly.

If one by one, then you need to have as many %d as you have ints:

Code (ags) Select

LMoney.Text=String.Format("%d, %d, %d, %d", Willis_Bank,  Meyers_Bank,  Mercer_Bank,  Guthrie_Bank);