• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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.

Errors when changing cries

  • 85
    Posts
    7
    Years
    • Seen Nov 24, 2023
    I'm not sure why this happens. I'm trying to edit my scripts for different purposes, but, when that script is supposed to happen ingame, I keep getting an error window which doesn't crash the game, but it gives me the "undefined method for nil:NilClass" message, even though said methods (species,battler etc) do exist in the script.

    Here's an example where I try to change Pikachu's fainting cry. For this one, the undefined method is "pokemon":
    Code:
    def pbFainted(pkmn)
        if isConst?(@battler.pokemon.species,PBSpecies,:PIKACHU)
          pbSEPlay("Cries/025Cry_Faint")
        else 
          frames=pbCryFrameLength(pkmn.pokemon)
          pbPlayCry(pkmn.pokemon)
        end
        .
        .
        .

    I'm guessing this could be a bug, since the script still plays out and doesn't crash the game, but the error window still pops up.
     
    Last edited:
    You are using variables that do not exist in that context. @battler doesn't exist in that context. However, the variable passed to that method pkmn is a battler object, so you can use that instead. You also don't need to go through pokemon to get the species, battlers have a species method that do the same thing.
     
    You are using variables that do not exist in that context. @battler doesn't exist in that context. However, the variable passed to that method pkmn is a battler object, so you can use that instead. You also don't need to go through pokemon to get the species, battlers have a species method that do the same thing.

    It worked now.Thanks a lot for the help!
     
    Back
    Top