Change Character Name ingame

Started by Helme, Wed 13/01/2010 22:54:51

Previous topic - Next topic

Helme

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.

ThreeOhFour

I don't actually have AGS installed at the moment (woah  :o) but can you not just use:

Code: ags
cCharacter.Name = "Julian";


(sorry, untested, but manual entry here suggests that this can get or set the name...)

Helme

I tried that without the " " - stupid me.
Thanks Ben!

ThreeOhFour

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.

monkey0506

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.

Code: ags
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'"):

Code: ags
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. ;)

ThreeOhFour


SMF spam blocked by CleanTalk