rigbycwts
Hmm, hmm.
- 94
- Posts
- 12
- Years
- Seen Feb 22, 2019
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.
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:
3. Then find pbEnterText (Line 1482) in PokemonTextEntry, and replace those lines of code with the following:
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.
1. Add the following lines at the end of Settings.
Code:
#===============================================================================
# Here is the array of censored words.
# Enclose words in quotes.
#===============================================================================
CENSORED_WORDS = []
Type down the words to be censored inside the brackets.
2. Create a new script section, name it PokemonWordFilter and add the following:
Code:
#===============================================================================
# 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:
Code:
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.