Name Input Tutorial - Banning Certain Strings

Discussion in 'RPG Maker MV Tutorials' started by Archeia, Sep 26, 2017.

  1. Archeia

    Archeia Level 99 Demi-fiend Staff Member

    Messages:
    13,153
    Likes Received:
    11,377
    Location:
    DEADLINE HELL
    First Language:
    Filipino
    Primarily Uses:
    VNM
    So your game allows the player to name their characters. But there's a catch, you don't want the player to name their main character with the same name as another character. Or worse, something unsavory. This tutorial is for cases like that.
    1. Create a text file of all the strings or phrases you want to ban from your game. For now I will go with "Ralph" and "Alex"
    2. Create a Common Event called "Name Input Processing"
    3. Create 2 Labels, One called START and One called VALID.
    Now under the label START, and assuming you can only name one character and we're going with Actor#1, put the Name Input Processing Command. Although this is optional and more about personal preference, I would put a Change Name command to set the name to blank. It should look something like this:
    Code:
    ◆Label:START
    ◆Change Name:PLAYER1,
    ◆Name Input Processing:PLAYER1, 7 characters
    ◆Label:VALID
    Insert a Conditional Branch with an else branch. Go to Page 4 and select Script. This is where we will insert the following code:
    Code:
    /BANNEDSTRING/i.exec($gameActors.actor(ID).name())
    So, since one of our banned strings is "Ralph", it should look like this:
    Code:
    /ralph/i.exec($gameActors.actor(1).name())
    And under the else command, just copy and paste this conditional branch and change "Ralph" to "Alex". You will end up something like this:

    Code:
    ◆Label:START
    ◆Change Name:PLAYER1,
    ◆Name Input Processing:PLAYER1, 7 characters
    ◆If:Script:/ralph/i.exec($gameActors.actor(1).name())
      ◆
    :Else
      ◆If:Script:/alex/i.exec($gameActors.actor(1).name())
        ◆
      :Else
        ◆
      :End
      ◆
    :End
    ◆Label:VALID
    As long as the strings "ralph" and "alex" are present, it doesn't matter what the case (upper or lower) of the name is, the system won't accept it.

    Now just above the Label: VALID, add a Show Message command that says something along the lines of "That name is already taken." and add a Jump to Label START. Then on the very last "else" of your conditional branch, add a Jump to Label VALID. By the end, your event command should look like this:

    Code:
    ◆Label:START
    ◆Change Name:PLAYER1,
    ◆Name Input Processing:PLAYER1, 7 characters
    ◆If:Script:/ralph/i.exec($gameActors.actor(1).name())
      ◆
    :Else
      ◆If:Script:/alex/i.exec($gameActors.actor(1).name())
        ◆
      :Else
        ◆Jump to Label:VALID
        ◆
      :End
      ◆
    :End
    ◆Text:None, Window, Bottom
    :    :That name is already taken.
    ◆Jump to Label:START
    ◆Label:VALID
    And that's about it! Now you just need to put it inside an event like this:
    Code:
    ◆Text:None, Window, Bottom
    :    :You want to name your character?
    ◆Common Event:Name Input Processing
    ◆Text:None, Window, Bottom
    :    :That's a really nice name \n[1]!
    Thank you @Shaz for helping me figure this out.
     
    #1
  2. Touchfuzzy

    Touchfuzzy Inevitable Staff Member

    Messages:
    5,650
    Likes Received:
    3,622
    Location:
    Athens, GA, USA
    First Language:
    English
    I once intentionally named every character in FFVII Sephiroth. It led to some very hard to follow conversations in game.
     
    #2

Share This Page