Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: x_traveler_x on Tue 08/03/2005 05:07:13

Title: Blank entry on InputGUI / default name [SOLVED]
Post by: x_traveler_x on Tue 08/03/2005 05:07:13
I'm trying to make an "enter your name" GUI.  It works, but I would like a default name to appear when nothing is entered in.

In other words, if the player types "George", then the character's name will be "George".  But if the player just clicks OK without entering a name, then his name will be "Carter".  Kinda like in the beginnings of the AGI Space Quest 1 & 2 .

Here's the code I used.  I can't figure out, for the life of me, why it won't work:


// ##### INPUTWINDOW #####

  if (interface == 10) {
    SetMouseCursor (6);
    if (button == 2){
      string charname;
      GetTextBoxText(10, 0, charname);
      if (charname == ""){
        StrCopy(charname,"Carter");
      }
      StrCopy(character[EGO].name, charname);
      GUIOff(10);
      SetDefaultCursor();
      Wait(1);
      Display("Your name is %s.", character[EGO].name);
    }
  }
Title: Re: Blank entry on InputGUI / default name
Post by: strazer on Tue 08/03/2005 05:30:19
Quotecharname == ""

This is not allowed. You have to use StrComp/StrCaseComp to check string values.
Title: Re: Blank entry on InputGUI / default name
Post by: x_traveler_x on Tue 08/03/2005 05:44:44
Gotcha!  I understand and it works perfectly.  Thank you, good sir!
Title: Re: Blank entry on InputGUI / default name
Post by: strazer on Tue 08/03/2005 06:11:38
You're welcome! :)