Page 1 of 1

Naming Player, RPG Style...?

PostPosted: Sat Jun 16, 2007 3:07 pm
by Jay S.
Chances are, in my project, the player will be able to name their characters whatever they wish. Their names will be a savable global string variable, and whatever the player types for their names would change the string variable to what is typed. :)

BUT, however, I cannot find a way so far to display the custom character names. For example, in a sentence someone would say, "Hey, [name here]!"

I'm trying to find a way to display the contents of the string variable in a sentence through an actor's text via code (with all of the rest of the text displayed.) Does anyone have any suggestions? :?

Re: Naming Player, RPG Style...?

PostPosted: Sun Jun 17, 2007 6:34 pm
by Asurai
Jay S. wrote:Chances are, in my project, the player will be able to name their characters whatever they wish. Their names will be a savable global string variable, and whatever the player types for their names would change the string variable to what is typed. :)

BUT, however, I cannot find a way so far to display the custom character names. For example, in a sentence someone would say, "Hey, [name here]!"

I'm trying to find a way to display the contents of the string variable in a sentence through an actor's text via code (with all of the rest of the text displayed.) Does anyone have any suggestions? :?

I havent messed much with this engine but in general displaying a string and a saved variable look like this
variable=32

the npc text will be = "hello i'm" + "variable"
syntax differ between different language but thats the general idea.
In C it looks similar to this
iAge = 32
Text 200,200,"Hello, World! I'm "+iAge+" years old!"

PostPosted: Sun Jun 17, 2007 8:04 pm
by Jay S.
I used this code:

Code: Select all
strcpy(variable, "text");
strcpy(actor.text, "Hello, my name is " +variable+ " !");


And I was able to use it, but when GE started, an error appeared saying there was a crash in the code. Is it somehow done differently than this in GE? :?

I hope someone knows. :P

PostPosted: Sun Jun 17, 2007 8:48 pm
by makslane
Use this code:

Code: Select all
sprintf(actor.text, "Hello, my name is %s !", variable);

PostPosted: Sun Jun 17, 2007 9:03 pm
by Jay S.
Bless you, my friend. Works like a charm. :)