Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: arj0n on Tue 18/11/2008 10:53:48

Title: Combining a string and text (or two strings)
Post by: arj0n on Tue 18/11/2008 10:53:48
I'm using AGS 3.1

I have an input box to get the game player name.
The name input is a string

I would like to display the text "welcome " followed by the name.

It would be something like this but the last line doesn't work...

function cEgo_Talk()
String A = Game.InputBox("!What is your name?");   
String B = ("Welcome ");
Display (BA&);

Should I use .append?
Title: Re: Combining a string and text (or two strings)
Post by: Gilbert on Wed 19/11/2008 14:10:17
If you don't need to keep the formatted text, just format it directly in the Display() line.

function cEgo_Talk(){
  String A = Game.InputBox("!What is your name?");   
  Display ("Welcome %s", A);
}
See the manual (http://www.adventuregamestudio.co.uk/manual/StringFormats.htm) for more details.
Title: Re: Combining a string and text (or two strings)
Post by: Dualnames on Fri 21/11/2008 09:57:53
function cEgo_Talk()
String A = Game.InputBox("!What is your name?");   
String B = "Welcome ";
B=B.Append(A);
Display (B);

Title: Re: Combining a string and text (or two strings)
Post by: arj0n on Fri 21/11/2008 11:29:28
Thanx guys :)