Make your own Name

Started by , Fri 22/04/2005 06:43:26

Previous topic - Next topic

supraman

I want to know how to type your name in at the start of the game and whenever a dialog talks about them, it uses the name they inputted in the start. Is it possible? If it helps, the type of game is The Wade Robson Project ( in other words, dancing.)

PsychicHeart

jst to clear something up, Supraman was me before I registered, so, when I post my In production thingo, that's my idea. Lol. I still want an answer 2 myquestion.
Formerly known as Flukeblake, Flukezy etc.

Scummbuddy

- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

Rd27

I did not quite understand this. Can someone please help me too how to make this own name thing.

I look the other thread scummbuddy linked, but I did not understand that.

Ashen

Which bit are you having trouble with?

All of the character names, set in the editor, are stored in strings like character[CHARID].name, e.g. character[EGO].name is 'Roger', for the player character.
All you need to do is prompt the player to input a name (with an InputBox () command like in the other thread, or a TextBox GUI), and save that input to the character[EGO].name string. Then instead of, for example:
Code: ags

DisplaySpeech (EGO, "Hello! I'm Roger.");

You'd use:
Code: ags

DisplaySpeech (EGO, "Hello! I'm %s.", character[EGO].name);
I know what you're thinking ... Don't think that.

Rd27

How do I make that input box?

string plrname;
InputBox(plrname, "What's your name?");
StrCopy(character[EGO].name,plrname);

Is it that? Where do I put it?

Thanks.

Ashen

#6
Yes, that's the InputBox code.
As to where you put it - it depends. Where ever you want to give the player a chance to set their name. It could be in a dialog, in the First time player enters screen of the first room, when they click on an object .... It may even be better to use a custom TextBox GUI, depending on your game.
Not much help, I know, sorry, but it's difficult to be specific without knowing when & how you want the player to supply their name.

EDIT: Since the BFAQ's back up, I'll point out this question about placing code, and this one about changing the player character name.

EDITED AGAIN: with more useful BFAQ link.
I know what you're thinking ... Don't think that.

TerranRich

Whew! I thought something happened to the Xylot.com domain name for good! Good to know it's back up. ;) Thanks, Ashen.
Status: Trying to come up with some ideas...

Rd27

I put that input box to come when player enters first time in the room.

But there is just a box with some cryptic fonts and it does not make difference if I put something for it.

Ashen

Well, Ishmael did say (in the other thread) he wasn't too sure of the parameters, and to look them up in the manual. If you'd done that, you'd have seen it should be InputBox ("What's your name?", plrname);, rather than the other way round, which might be a start.
I know what you're thinking ... Don't think that.

storycatchermike

I'm having problems. I want to make the player select the character's name, but I have tried all of the things you have said to do, and I keep getting an error, saying that my strings are not being recognized. What am I doing wrong?
Code: ags
  InputBox("Hello, what's your name?",plrname);
  StrCopy(character[EGO].name,plrname);
  Display("Well, nice to meet you %s",character[EGO].plrname);

Can someone help me with this?
Story Catcher Mike (Founder of Knights Creations)
Upcoming AGS game by me: Sir Tilean and the Way of the Knight (Game Total = 5%)

strazer

  string plrname; // define string variable that will hold the new name
  InputBox("Hello, what's your name?", plrname); // ask for name and store it in the variable
  // you might want to add some checks here, in case the user entered no text for example
  StrCopy(character[EGO].name, plrname); // copy text from variable to character's name
  Display("Well, nice to meet you %s", character[EGO].plrname); // display the character's name
    // i.e. the above should be character[EGO].name

Alternatively, in this particular script,

  Display("Well, nice to meet you %s", plrname); // display the variable's text

would also work since at that point the variable and the character's name contain the same text. However, when the function ends, the local string variable is destroyed and you have to use character[EGO].name instead (i.e. in other functions).

storycatchermike

And exactly how do you go about doing that? I'm not quite sure how to set the script so it checks things. Although, your code did work, so thanks alot, I owe you one!
Story Catcher Mike (Founder of Knights Creations)
Upcoming AGS game by me: Sir Tilean and the Way of the Knight (Game Total = 5%)

strazer

You're welcome. :)

To check if the player entered text at all, you could do:

Code: ags

  //...
  if (StrComp(plrname, "") != 0) { // if player entered text
    StrCopy(character[EGO].name, plrname); // copy text from variable to character's name
  }
  //...

storycatchermike

Well, I just tried your idea, and all it did was make it so there was no name put in. If I didn't put in a name, it gave it a blank name, but if I did put something in, it still had a blank name, so that idea didn't work...you think you know any other ideas?
Story Catcher Mike (Founder of Knights Creations)
Upcoming AGS game by me: Sir Tilean and the Way of the Knight (Game Total = 5%)

strazer

This is the full code and it should work:

Code: ags

  string plrname; // define string variable that will hold the new name
  InputBox("Hello, what's your name?", plrname); // ask for name and store it in the variable
  if (StrComp(plrname, "") != 0) // if player entered text
    StrCopy(character[EGO].name, plrname); // copy text from variable to character's name
  Display("Well, nice to meet you %s", character[EGO].name); // display the character's name


You probably forgot to remove the old StrCopy command.

storycatchermike

Well, that sort of worked. Now, I'm getting the character's actual name instead of a blank line. I was hoping, though, that I would be able to make it so it would make it so you can't push the "ok" button until there is at least 1 letter in it.
Story Catcher Mike (Founder of Knights Creations)
Upcoming AGS game by me: Sir Tilean and the Way of the Knight (Game Total = 5%)


SCMike

I need help with this again, with the upgrade to AGS 2.7, this doesn't seem to work anymore...I'm getting an error saying that something doesn't work in it...something about the text not being right or something...

Scummbuddy

press Ctrl+C when the error pops up, and then Ctrl+V when you write your next reply here, because we can not help you without the approrpriate error message
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

SMF spam blocked by CleanTalk