NAME INPUT TUTORIAL - BANNING CERTAIN STRINGS

Ban certain strings from character names.

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.

- 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"
- Create a Common Event called "Name Input Processing"
- 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:

◆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:
/BANNEDSTRING/i.exec($gameActors.actor(ID).name())


So, since one of our banned strings is "Ralph", it should look like this:
/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:

◆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:

◆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:

◆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.