• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Scottie, Todd, Serena, Kris - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Set default rival name if blanked?

  • 69
    Posts
    10
    Years
    I know how to ask for the rival's name, and also have one entered for you to change, but what I don't know is how to make it so if the name entry is blank, then it just assumes the same name previously preset.
    To see what I mean, look at this script.
    Code:
    pbSet(12,pbEnterText("Rival's name?",1,7,"Blue"))
    Now how do I make it that if no text is entered, the default name is set to "Blue"?
     
    Something like this should work:

    Code:
    if $game_variables[12]==""
    $game_variables[12]="Blue"
    end

    Just put it right after:

    Code:
    pbSet(12,pbEnterText("Rival's name?",1,7,"Blue"))

    I haven't scripted in ages, but it should work.
     
    Something like this should work:

    Code:
    if $game_variables[12]==""
    $game_variables[12]="Blue"
    end
    Just put it right after:

    Code:
    pbSet(12,pbEnterText("Rival's name?",1,7,"Blue"))
    I haven't scripted in ages, but it should work.

    When I try it, it still reads it as a blank name (the confirmation screen is " , right?").
     
    I still need help right now! :(

    " , right?"
    That's a space, not an empty string. Spaces have ascii values still, they are characters. If you want to avoid those, maybe something like
    Code:
    pbSet(12,pbEnterText("Rival's name?",0,7,"Blue"))
    count=0
    for char in $game_variables[12]
    count+=1 if char!=' '
    end
    if $game_variables[12]=="" || count==0
    $game_variables[12]="Blue"
    end
     
    That's a space, not an empty string. Spaces have ascii values still, they are characters. If you want to avoid those, maybe something like
    Code:
    pbSet(12,pbEnterText("Rival's name?",0,7,"Blue"))
    count=0
    for char in $game_variables[12]
    count+=1 if char!=' '
    end
    if $game_variables[12]=="" || count==0
    $game_variables[12]="Blue"
    end

    because before the line was
    Code:
    pbSet(12,pbEnterText("Rival's name?",1,7,"Blue"))
    thats what was messing it up because there was a space because the 1
    changing that line from a 1 to a 0 is all thats needed, i tested it and it works fine
     
    because before the line was
    Code:
    pbSet(12,pbEnterText("Rival's name?",1,7,"Blue"))
    thats what was messing it up because there was a space because the 1
    changing that line from a 1 to a 0 is all thats needed, i tested it and it works fine

    I thought he was entering a space and not wanting the user to be able to do that.
     
    Back
    Top