• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] Renaming Pokemon in Party screen help

Rinkoou

Awful-Pun Master
54
Posts
7
Years
  • Hello! I've been trying to add a feature which I've been wanting for a while, which is renaming your Pokemon within the party screen. Using Ego13's PokeID script as a base, I've made this abomination:
    Code:
    module PokemonRename
      def pbPokemonRenameCommand
      commands.add("main","rename",_INTL("Rename"))
        return commands
      end
    
      def pbPokemonRenameAction(command,pkmn,pkmnid,heldpoke=nil)
        case command
        
        when "rename"
          cmd = 0
          loop do
            speciesname = PBSpecies.getName(pkmn.species)
            msg = [_INTL("{1} has the nickname {2}.",speciesname,pkmn.name),
                   _INTL("{1} has no nickname.",speciesname)][pkmn.name==speciesname ? 1 : 0]
            cmd = scene.pbShowCommands(msg,[
                 _INTL("Rename"),
                 _INTL("Erase name")],cmd)
            break if cmd<0
            case cmd
            when 0   # Rename
              oldname = (pkmn.name && pkmn.name!=speciesname) ? pkmn.name : ""
              oldname = speciesname if oldname==""
              newname = pbEnterPokemonName(_INTL("{1}'s nickname?",speciesname),
                 0,PokeBattle_Pokemon::NAMELIMIT,oldname,pkmn)
              if newname && newname!="" && !pokemon.isForeign?($Trainer)
                pkmn.name = newname
                scene.pbRefresh
              elsif newname && newname!="" && pokemon.isForeign?($Trainer)
                scene.pbDisplay(_INTL("#{newname} doesn't seem to react to its new name. You quickly went back to calling it #{oldname}."))
                pokemon.name=oldname
                scene.pbRefresh
              end
            when 1   # Erase name
              oldname = (pkmn.name && pkmn.name!=speciesname) ? pkmn.name : ""
            if !pokemon.isForeign?($Trainer)
              pkmn.name = speciesname
              scene.pbRefresh
            elsif pokemon.isForeign?($Trainer) && oldname!=""
                scene.pbDisplay(_INTL("#{speciesname} doesn't seem to react. You quickly went back to calling it #{oldname}."))
                scene.pbRefresh
            elsif oldname==""
                scene.pbDisplay(_INTL("#{speciesname} doesn't have a nickname."))
            end
          end
        end
      end
    end

    Not surprisingly, it doesn't work. If anybody could help with it, I'd greatly appreciate it!
     

    Rinkoou

    Awful-Pun Master
    54
    Posts
    7
    Years
  • Oh hey. I just put it in its own script above Main. When I try starting up the game, it just tells me that theres a stynax error on the last line.
     

    Ego13

    hollow_ego
    311
    Posts
    6
    Years
  • Ah then it should be easy. According to my analysis you are missing an "end" at the very bottom. It is the missing end for the module
     

    Rinkoou

    Awful-Pun Master
    54
    Posts
    7
    Years
  • Like I said, I just put the code in a new script section above Main. The code is:
    Code:
    module PokemonRename
      def pbPokemonRenameCommand
      commands.add("main","rename",_INTL("Rename"))
        return commands
      end
    
      def pbPokemonRenameAction(command,pkmn,pkmnid,heldpoke=nil)
        case command
        
        when "rename"
          cmd = 0
          loop do
            speciesname = PBSpecies.getName(pkmn.species)
            msg = [_INTL("{1} has the nickname {2}.",speciesname,pkmn.name),
                   _INTL("{1} has no nickname.",speciesname)][pkmn.name==speciesname ? 1 : 0]
            cmd = scene.pbShowCommands(msg,[
                 _INTL("Rename"),
                 _INTL("Erase name")],cmd)
            break if cmd<0
            case cmd
            when 0   # Rename
              oldname = (pkmn.name && pkmn.name!=speciesname) ? pkmn.name : ""
              oldname = speciesname if oldname==""
              newname = pbEnterPokemonName(_INTL("{1}'s nickname?",speciesname),
                 0,PokeBattle_Pokemon::NAMELIMIT,oldname,pkmn)
              if newname && newname!="" && !pokemon.isForeign?($Trainer)
                pkmn.name = newname
                scene.pbRefresh
              elsif newname && newname!="" && pokemon.isForeign?($Trainer)
                scene.pbDisplay(_INTL("#{newname} doesn't seem to react to its new name. You quickly went back to calling it #{oldname}."))
                pokemon.name=oldname
                scene.pbRefresh
              end
            when 1   # Erase name
              oldname = (pkmn.name && pkmn.name!=speciesname) ? pkmn.name : ""
            if !pokemon.isForeign?($Trainer)
              pkmn.name = speciesname
              scene.pbRefresh
            elsif pokemon.isForeign?($Trainer) && oldname!=""
                scene.pbDisplay(_INTL("#{speciesname} doesn't seem to react. You quickly went back to calling it #{oldname}."))
                scene.pbRefresh
            elsif oldname==""
                scene.pbDisplay(_INTL("#{speciesname} doesn't have a nickname."))
            end
          end
        end
      end
    end
    end
    Also, like I said, the game doesn't crash anymore but when I go to the party screen and go to the options, the option to rename isn't there.
     

    Ego13

    hollow_ego
    311
    Posts
    6
    Years
  • Just putting the whole thing above main wont makethe options appear.

    Did you add the option in
    Code:
    def pbPokemonScreen
    ?


    # -------------------------------------------------------------------------------------------------------
    Because I just had to test it for myself: First thing i noticed is how you split the whole code in two parts. Not sure why you did this though.

    I created a new script section above main and called it "Other" (but really can be named whatever you want or even place the code in a different script section). Thats where I put this code:

    Code:
    #Poke ID
    def renamePokemon(pokemon)
      pkmn=pokemon    
      cmd = 0
          loop do
            speciesname = PBSpecies.getName(pkmn.species)
            msg = [_INTL("{1} has the nickname {2}.",speciesname,pkmn.name),
                   _INTL("{1} has no nickname.",speciesname)][pkmn.name==speciesname ? 1 : 0]
            cmd = scene.pbShowCommands(msg,[
                 _INTL("Rename"),
                 _INTL("Erase name")],cmd)
            break if cmd<0
            case cmd
            when 0   # Rename
              oldname = (pkmn.name && pkmn.name!=speciesname) ? pkmn.name : ""
              oldname = speciesname if oldname==""
              newname = pbEnterPokemonName(_INTL("{1}'s nickname?",speciesname),
                 0,PokeBattle_Pokemon::NAMELIMIT,oldname,pkmn)
              if newname && newname!="" && (!pokemon.isForeign?($Trainer) || (pokemon.isForeign?($Trainer) && pokemon.happiness==255 ))
                scene.pbDisplay(_INTL("#{newname} doesn't mind the name change anymore.")) if (pokemon.isForeign?($Trainer) && pokemon.happiness==255 )
                pkmn.name = newname
                scene.pbRefresh
              elsif newname && newname!="" && pokemon.isForeign?($Trainer)
                scene.pbDisplay(_INTL("#{newname} doesn't seem to react to its new name. You quickly went back to calling it #{oldname}."))
                pokemon.name=oldname
                scene.pbRefresh
              end
            when 1   # Erase name
              oldname = (pkmn.name && pkmn.name!=speciesname) ? pkmn.name : ""
            if (!pokemon.isForeign?($Trainer) || (pokemon.isForeign?($Trainer) && pokemon.happiness==255 )) && oldname!=""
              scene.pbDisplay(_INTL("#{speciesname} doesn't mind the name change anymore.")) if (pokemon.isForeign?($Trainer) && pokemon.happiness==255 )
              pkmn.name = speciesname
              scene.pbRefresh
            elsif pokemon.isForeign?($Trainer) && oldname!=""
                scene.pbDisplay(_INTL("#{speciesname} doesn't seem to react. You quickly went back to calling it #{oldname}."))
                scene.pbRefresh
              elsif oldname==""
                scene.pbDisplay(_INTL("#{speciesname} doesn't have a nickname."))
              end
            end
          end
       
    end

    Then in PScreen_Party under
    Code:
    pkmn = @party[pkmnid]
          commands   = []
          cmdSummary = -1
          cmdDebug   = -1
          cmdMoves   = [-1,-1,-1,-1]
          cmdSwitch  = -1
          cmdMail    = -1
          cmdItem    = -1

    add

    Code:
    cmdRename  = -1

    and under
    Code:
    if !pkmn.egg?
            if pkmn.mail
              commands[cmdMail = commands.length]     = _INTL("Mail")
            else
              commands[cmdItem = commands.length]     = _INTL("Item")
            end
          end

    place
    Code:
    commands[cmdRename = commands.length]      = _INTL("Rename")
    you could also place it up higher depending on where you want it to show up (like before Summary or after or whatever)

    and last, under
    Code:
       next if havecommand
          if cmdSummary>=0 && command==cmdSummary
            @scene.pbSummary(pkmnid)
    Place

    Code:
    elsif cmdRename>=0 && command==cmdRename
            renamePokemon(pkmn)

    Now you should be able to rename your mons on the go. I tested it with essentials v16.2
     
    Back
    Top