Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Helme on Wed 13/01/2010 22:54:51

Title: Change Character Name ingame
Post by: Helme on Wed 13/01/2010 22:54:51
Sorry for the noobish question:

How can I change the 'realname' of a character in the game? I searched the forum for the question but the answers are too old to work.
Title: Re: Change Character Name ingame
Post by: ThreeOhFour on Wed 13/01/2010 23:09:19
I don't actually have AGS installed at the moment (woah  :o) but can you not just use:

cCharacter.Name = "Julian";

(sorry, untested, but manual entry here (http://www.americangirlscouts.org/agswiki/Character_functions_and_properties#Character.Name) suggests that this can get or set the name...)
Title: Re: Change Character Name ingame
Post by: Helme on Wed 13/01/2010 23:17:59
I tried that without the " " - stupid me.
Thanks Ben!
Title: Re: Change Character Name ingame
Post by: ThreeOhFour on Wed 13/01/2010 23:23:24
Glad it worked!

I'm not sure of the rules precisely (I'm sure somebody can clarify here) but I believe whenever you're setting a string variable's value it is necessary to use the quotation marks.
Title: Re: Change Character Name ingame
Post by: monkey0506 on Wed 13/01/2010 23:28:35
Basically the reason you need the quotes is because you're working with plain text. Any time you want to use plain text (as opposed to the scripting language) you must enclose it in quotes.

String text = "This is some text!";

If you forget then then it will try to interpret the text as script (which usually doesn't make sense and will give an error such as, "Unexpected 'This'"):

String text = This is some text!;

That doesn't work because "This", "is", and "some" are all undefined, "text" is the current object being defined so that might kick up an error there too and finally you have an illegal use of the ! operator. :D

So just remember if you want to put plain text in your script it must be enclosed in quotation marks "like this".

This is called a "string literal" when the text is enclosed this way. It means that it's the literal text value that you want to place into a String variable or use as a function parameter. ;)
Title: Re: Change Character Name ingame
Post by: ThreeOhFour on Wed 13/01/2010 23:34:44
Thanks for that, monkey  :-*