Blank entry on InputGUI / default name [SOLVED]

Started by x_traveler_x, Tue 08/03/2005 05:07:13

Previous topic - Next topic

x_traveler_x

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:

Code: ags

// ##### 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);
    }
  }
~~- - -. . .finding a cure for mundanity. . . - - -~~

strazer

Quotecharname == ""

This is not allowed. You have to use StrComp/StrCaseComp to check string values.

x_traveler_x

Gotcha!  I understand and it works perfectly.  Thank you, good sir!
~~- - -. . .finding a cure for mundanity. . . - - -~~


SMF spam blocked by CleanTalk