Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: MorpheusKitami on Sat 07/12/2019 00:56:54

Title: Variables in Labels?
Post by: MorpheusKitami on Sat 07/12/2019 00:56:54
So, instead of doing text like a normal person through the standard format, I'm instead using a Label on the GUI to display text. This has so far not caused me any trouble. However when I try adding a variable to it, it gives me a parse error. Am I doing something wrong or is this just not possible?

Code (ags) Select

Label1.Text = ("Its a 44-70 Hans & Rogers pump-action rifle. It has %d rounds left.", rifle_ammo);
Title: Re: Variables in Labels?
Post by: Crimson Wizard on Sat 07/12/2019 00:59:22
Use String.Format, it creates a formatted string which you can assign anywhere.

Code (ags) Select

Label1.Text = String.Format("Its a 44-70 Hans & Rogers pump-action rifle. It has %d rounds left.", rifle_ammo);
Title: Re: Variables in Labels?
Post by: MorpheusKitami on Sun 08/12/2019 06:01:52
Thanks, I apologize for asking such a simple question but searching provided me with no obvious results.