Nickname from the party

v21.1 Nickname from the party N/A

This resource pertains to version 21.1 of Pokémon Essentials.
Pokémon Essentials Version
v21.1 ✅
name.png


Simple script to add the ability to nickname Pokémon from the party screen. v20/v21 has a plugin, which can be found here. This script was originally developed in v17, so I've included the older versions here as well.


Code​

Paste in a new script section above Main, or download as a plugin here.
Ruby:
MenuHandlers.add(:party_menu, :rename, {
  "name"      => _INTL("Rename"),
  "order"     => 55,
  "condition" => proc { |screen, party, party_idx| next !party[party_idx].egg? },
  "effect"    => proc { |screen, party, party_idx|
    pkmn = party[party_idx]
    name = pbMessageFreeText("#{pkmn.speciesName}'s nickname?",_INTL(""),false,Pokemon::MAX_NAME_SIZE)  { screen.pbUpdate }
    name=pkmn.speciesName if name ==""
    pkmn.name=name
    screen.pbDisplay(_INTL("{1} was renamed to {2}.",pkmn.speciesName,pkmn.name))
  }
})

I've done this without any restrictions apart from the egg, because I think the trend of not naming Shadow/Foreign Pokemon is dumb. If you want to add that, change

!party[party_idx].egg?

to

(!party[party_idx].egg? && !party[party_idx].foreign? && !party[party_idx].shadowPokemon?)

In UI_Party, find this section:
Ruby:
      commands   = []
      cmdSummary = -1
      cmdDebug   = -1
      cmdMoves   = [-1,-1,-1,-1]
      cmdSwitch  = -1
      cmdMail    = -1
      cmdItem    = -1
Add this line:
Ruby:
      cmdRename  = -1
Renaming actually works just fine without this, except skipping this step results in a crash when hitting Cancel on an egg. If you're getting an error like that, this is probably your fix!

Next, find this section.
Ruby:
      commands[cmdSwitch = commands.length]       = _INTL("Switch") if @party.length>1
      if !pkmn.egg?
        if pkmn.mail
          commands[cmdMail = commands.length]     = _INTL("Mail")
        else
          commands[cmdItem = commands.length]     = _INTL("Item")
        end
      end
After that first end, paste this:
Ruby:
          commands[cmdRename = commands.length]     = _INTL("Rename")
It should look like this now:
Ruby:
      commands[cmdSwitch = commands.length]       = _INTL("Switch") if @party.length>1
      if !pkmn.egg?
        if pkmn.mail
          commands[cmdMail = commands.length]     = _INTL("Mail")
        else
          commands[cmdItem = commands.length]     = _INTL("Item")
        end
          commands[cmdRename = commands.length]     = _INTL("Rename")
      end

Now, locate this section further down:
Ruby:
              if pbConfirm(_INTL("Would you like to switch the two items?"))
                newpkmn.setItem(item)
                pkmn.setItem(newitem)
                @scene.pbClearSwitching
                pbRefresh
                pbDisplay(_INTL("{1} was given the {2} to hold.",newpkmn.name,itemname))
                pbDisplay(_INTL("{1} was given the {2} to hold.",pkmn.name,newitemname))
                break
              end
            end
          end
        end
After the fourth end, add this:
Ruby:
      elsif cmdRename>=0 && command==cmdRename
        $game_variables[5]=pbMessageFreeText("#{pkmn.speciesName}'s nickname?",_INTL(""),false,Pokemon::MAX_NAME_SIZE)
            if pbGet(5)==""
              pkmn.name=pkmn.speciesName
              pbSet(5,pkmn.name)
            end
        pkmn.name=pbGet(5)
        pbDisplay(_INTL("{1} was renamed to {2}.",pkmn.speciesName,pkmn.name))


If you'd like to use the cursor naming instead of the keyboard, change this line:

Ruby:
        $game_variables[5]=pbMessageFreeText("#{pkmn.speciesName}'s nickname?",_INTL(""),false,Pokemon::MAX_NAME_SIZE)

to
Ruby:
        $game_variables[5]=pbEnterPokemonName(_INTL("{1}'s nickname?", pkmn.speciesName),
                                 0, Pokemon::MAX_NAME_SIZE, "", pkmn)


I've done this without any restrictions apart from the egg, because I think the trend of not naming Shadow/Foreign Pokemon is dumb. But you could easily implement that by adding a little conditional branch.

Go back to this section:
Ruby:
      commands[cmdSwitch = commands.length]       = _INTL("Switch") if @party.length>1
      if !pkmn.egg?
        if pkmn.mail
          commands[cmdMail = commands.length]     = _INTL("Mail")
        else
          commands[cmdItem = commands.length]     = _INTL("Item")
        end
          commands[cmdRename = commands.length]     = _INTL("Rename")
      end
Before the Rename command, add a conditional if that checks if the Pokemon is foreign or Shadow.
Ruby:
          if !pkmn.foreign?($Trainer) && !pkmn.shadowPokemon?


And then just add another "end" after the line:
Ruby:
                commands[cmdRename = commands.length]     = _INTL("Rename")
You mostly follow the same steps, there's just enough changes in the code that I wanted to have this be a separate section lmao


In UI_Party (PScreen_Party in earlier version), find this section:
Ruby:
      commands   = []
      cmdSummary = -1
      cmdDebug   = -1
      cmdMoves   = [-1,-1,-1,-1]
      cmdSwitch  = -1
      cmdMail    = -1
      cmdItem    = -1
Add this line:
Ruby:
      cmdRename  = -1
Renaming actually works just fine without this, except skipping this step results in a crash when hitting Cancel on an egg. If you're getting an error like that, this is probably your fix!


Next, find this section.
Ruby:
      commands[cmdSwitch = commands.length]       = _INTL("Switch") if @party.length>1
      if !pkmn.egg?
        if pkmn.mail
          commands[cmdMail = commands.length]     = _INTL("Mail")
        else
          commands[cmdItem = commands.length]     = _INTL("Item")
        end
      end
After that first end, paste this:
Ruby:
          commands[cmdRename = commands.length]     = _INTL("Rename")
It should look like this now:
Ruby:
      commands[cmdSwitch = commands.length]       = _INTL("Switch") if @party.length>1
      if !pkmn.egg?
        if pkmn.mail
          commands[cmdMail = commands.length]     = _INTL("Mail")
        else
          commands[cmdItem = commands.length]     = _INTL("Item")
        end
          commands[cmdRename = commands.length]     = _INTL("Rename")
      end


Now, locate this section further down:
Ruby:
              if pbConfirm(_INTL("Would you like to switch the two items?"))
                newpkmn.setItem(item)
                pkmn.setItem(newitem)
                @scene.pbClearSwitching
                pbRefresh
                pbDisplay(_INTL("{1} was given the {2} to hold.",newpkmn.name,itemname))
                pbDisplay(_INTL("{1} was given the {2} to hold.",pkmn.name,newitemname))
                break
              end
            end
          end
        end
After the fourth end, add this:
Ruby:
      elsif cmdRename>=0 && command==cmdRename
        species=PBSpecies.getName(pkmn.species)
        $game_variables[5]=Kernel.pbMessageFreeText("#{species}'s nickname?",_INTL(""),false,13)
            if pbGet(5)==""
              pbSet(5,species)
            end
        pkmn.name=pbGet(5)
        pbDisplay(_INTL("{1} was renamed to {2}.",species,pkmn.name))


Note that the 13 is the character limit for the name- you may want to adjust that to your tastes, but remember to keep it an amount that would be legible in gameplay.

Depending on your version, you might be able to delete "Kernel" if you want, but it doesn't hurt to leave it in.

If you'd like to use the cursor naming instead of the keyboard, change this line:

Ruby:
        $game_variables[5]=Kernel.pbMessageFreeText("#{species}'s nickname?",_INTL(""),false,13)

to

Ruby:
        $game_variables[5]=pbEnterPokemonName(_INTL("{1}'s nickname?", species),
                                 0, 13, "", pkmn)
With 13 being the max name size.

I've done this without any restrictions apart from the egg, because I think the trend of not naming Shadow/Foreign Pokemon is dumb. But you could easily implement that by adding a little conditional branch.

Go back to this section:
Ruby:
      commands[cmdSwitch = commands.length]       = _INTL("Switch") if @party.length>1
      if !pkmn.egg?
        if pkmn.mail
          commands[cmdMail = commands.length]     = _INTL("Mail")
        else
          commands[cmdItem = commands.length]     = _INTL("Item")
        end
          commands[cmdRename = commands.length]     = _INTL("Rename")
      end
Before the Rename command, add a conditional if that checks if the Pokemon is foreign or Shadow.

Ruby:
          if !pkmn.isForeign?($Trainer) && !pkmn.isShadow?

And then just add another "end" after the line:
Ruby:
                commands[cmdRename = commands.length]     = _INTL("Rename")
Credits
Credits to TechSkylander1518, please!
Author
TechSkylander1518
Downloads
938
Views
5,967
First release
Last update
Rating
5.00 star(s) 3 ratings

More resources from TechSkylander1518

Latest updates

  1. Minor update

    Super quick update that keeps the screen updating while you enter the name. (I wouldn't include...
  2. v20 Update

    Quick update for v20 compatibility. A plugin can now be downloaded here.
  3. v19 Update

    Updated for v19! The code for v18 is still there, it's just been bumped down! Also, if you...

Latest reviews

This was really easy to implement and worked like a charm. Thank you!
Top