Author Topic: Multiple variables in string formatting. SOLVED  (Read 205 times)

Greetings,

I have this line,
Code: Adventure Game Studio
  1. lPlayerInfoHP.Text = String.Format("-Health: %d/20", citizens[0].hp);
         

I'd like the "20" to be another variable (citizens[0].hpcore)

I'm looking at the manual and seeing that it's possible to have as many variables as you like in one line but after playing around for a bit I can't figure it out.

Thanks in advance for any help.
« Last Edit: 16 Oct 2021, 22:16 by Pax Animo »
I'm a slow learner but I like to ask questions.

Peckham 1503 11/21 Devlog available.
https://pax-animo.itch.io/pecham-1503

Pogwizd

  • Quidquid latine dictum sit altum videtur
    • Pogwizd worked on one or more games that was nominated for an AGS Award!
Re: Multiple variables in string formatting.
« Reply #1 on: 14 Oct 2021, 12:14 »
Wouldn’t this work?:
Code: Adventure Game Studio
  1. PlayerInfoHP.Text = String.Format("-Health: %d/%d", citizens[0].hp, secondInt);
  2.  

Re: Multiple variables in string formatting.
« Reply #2 on: 14 Oct 2021, 12:26 »
Wouldn’t this work?:
Code: Adventure Game Studio
  1. PlayerInfoHP.Text = String.Format("-Health: %d/%d", citizens[0].hp, secondInt);
  2.  

That works fine now.
On my attempts I some how messed up where to place the (,'s).

Thank you.
I'm a slow learner but I like to ask questions.

Peckham 1503 11/21 Devlog available.
https://pax-animo.itch.io/pecham-1503