Jibble

Author Topic: Variables in Labels?  (Read 399 times)

Variables in Labels?
« on: 07 Dec 2019, 00:56 »
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: Adventure Game Studio
  1. Label1.Text = ("Its a 44-70 Hans & Rogers pump-action rifle. It has %d rounds left.", rifle_ammo);
  2.  

Re: Variables in Labels?
« Reply #1 on: 07 Dec 2019, 00:59 »
Use String.Format, it creates a formatted string which you can assign anywhere.

Code: Adventure Game Studio
  1. Label1.Text = String.Format("Its a 44-70 Hans & Rogers pump-action rifle. It has %d rounds left.", rifle_ammo);
  2.  

Re: Variables in Labels?
« Reply #2 on: 08 Dec 2019, 06:01 »
Thanks, I apologize for asking such a simple question but searching provided me with no obvious results.