Naming Player, RPG Style...?

Non-platform specific questions.

Naming Player, RPG Style...?

Postby Jay S. » Sat Jun 16, 2007 3:07 pm

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? :?
User avatar
Jay S.
 
Posts: 118
Joined: Thu Apr 26, 2007 6:51 pm
Location: My computer desk. :P
Score: 9 Give a positive score

Re: Naming Player, RPG Style...?

Postby Asurai » Sun Jun 17, 2007 6:34 pm

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!"
Asurai
 
Posts: 4
Joined: Tue Jun 05, 2007 2:43 am
Score: 0 Give a positive score

Postby Jay S. » Sun Jun 17, 2007 8:04 pm

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
User avatar
Jay S.
 
Posts: 118
Joined: Thu Apr 26, 2007 6:51 pm
Location: My computer desk. :P
Score: 9 Give a positive score

Postby makslane » Sun Jun 17, 2007 8:48 pm

Use this code:

Code: Select all
sprintf(actor.text, "Hello, my name is %s !", variable);
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Jay S. » Sun Jun 17, 2007 9:03 pm

Bless you, my friend. Works like a charm. :)
User avatar
Jay S.
 
Posts: 118
Joined: Thu Apr 26, 2007 6:51 pm
Location: My computer desk. :P
Score: 9 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest