PDA

View Full Version : [Essentials script] Pokemon Nickname Word Filter


rigbycwts
May 17th, 2013, 06:29 PM
After messing around with Ruby, I managed to create a word filter for Essentials games.

1. Add the following lines at the end of Settings.

#===============================================================================
# Here is the array of censored words.
# Enclose words in quotes.
#===============================================================================
CENSORED_WORDS = []

Note that the words must be enclosed in quotes.
Type down the words to be censored inside the brackets.

2. Create a new script section, name it PokemonWordFilter and add the following:

#===============================================================================
# Word Filter
# By rigbycwts
#
# Note:
# Starting on Gen 5, the main series games have a built-in word filter.
# The censor only prevents inputs in which exactly match the keyword.
# However, previously, when trying to trade a Pokémon on the GTS,
# the keyword only had to be contained in the name. This caused problems with
# Pokémon whose names contained the keyword, such as Cofagrigus,
# preventing them from being traded without nicknames,
# so the filter was eventually removed.
#
# However, the filter still prevents some Pokémon from being traded,
# such as Nosepass.
#
# Algorithm:
# 1. Checks input text, creates a copy of it and converts it to uppercase.
# 2. If input text contains or matches the filtered word,
# it does not process the text, and returns to the text input screen.
# 3. If input text does not contain or match the filtered word,
# the usual processing happens.
#===============================================================================

# Separate filters for Pokemon names, PC Boxes, Player names and Mail messages

# For Pokemon Names: Aside from the restriction above, a Pokemon can't be nicknamed
# with the name of another Pokemon. Example: You can't name a Typhlosion "Charizard."
def CheckPokemonNickname(nickname)
nicknameCopy=nickname.upcase
for i in 0...CENSORED_WORDS.length
# Exact match
if nicknameCopy=~CENSORED_WORDS[i]
return true
end
end
# Not a censored word.
return false
end


3. Then find pbEnterText (Line 1482) in PokemonTextEntry, and replace those lines of code with the following:

def pbEnterText(helptext,minlength,maxlength,initialText="")
ret=""
if USEKEYBOARDTEXTENTRY
pbFadeOutIn(99999){
sscene=PokemonEntryScene.new
sscreen=PokemonEntry.new(sscene)
ret=sscreen.pbStartScreen(helptext,minlength,maxlength,initialText)
}
else
pbFadeOutIn(99999){
sscene=PokemonEntryScene2.new
sscreen=PokemonEntry.new(sscene)
ret=sscreen.pbStartScreen(helptext,minlength,maxlength,initialText)
}
end
# Insert word filter here.
# If maxlength is 10, apply Pokemon nickname filter.
if (maxlength == 10)
if CheckPokemonNickname(ret)
Kernel.pbMessage(_INTL("You can't use an inappropriate name for your Pokemon!"))
ret=initialText
pbEnterText(helptext,minlength,maxlength,initialText)
else
return ret
end
end
# If maxlength is 7, apply player name filter.

# Filter bypassed.
else
return ret
end


If there are missing things, please let me know. Not all things like making it unable to nickname a Pokemon the name of another Pokemon (e.g. giving the name "Typhlosion" to a Charizard) are implemented.

Nickalooose
May 20th, 2013, 04:14 AM
Good idea, but since online battles and trading don't exist... There is no point to it... If someone wants to give their Pokemon a disgusting name, that's up to them... You probably could've made this simpler by edit pbEnterText, and using that CENSOREDWORDS filter within that, but nice script anyway :)

rigbycwts
May 20th, 2013, 06:22 PM
Good idea, but since online battles and trading don't exist... There is no point to it... If someone wants to give their Pokemon a disgusting name, that's up to them... You probably could've made this simpler by edit pbEnterText, and using that CENSOREDWORDS filter within that, but nice script anyway :)
That could come in handy if someone (myself included) wants a GTS for their games. Just in case.

ISNorden
May 31st, 2013, 11:30 PM
It's a shame that the banned-names filter can't include some kind of "whitelist/valid exceptions" code; I've seen this technique used on Wikipedia, where the filter of banned username strings is paired with a whitelist of acceptable words that would otherwise be blocked. If the scripting language permits it, then designating the problem species names (Cofagrigus, Probopass, and Nosepass) as exceptions should end the GTS rejections.