• 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] Error in Egg hatching Progress (maybe sound bug?)

Heppy8787

H3ppY
  • 2
    Posts
    3
    Years
    Hello, i have an error when hatching an egg.

    the pokemon appears and maybe the cry should follow but then the errors shows up.
    the errors says:
    Script "PSystem_FileUtilities' line 425: ArgumentError aoourred.
    wrong number of arguments (2 for 1)
    what does that mean? :-(

    this is the script part:

    Code:
    #===============================================================================
    # Analyse audio files
    #===============================================================================
    def pbResolveAudioSE(file)
      return nil if !file
      if RTP.exists?("Audio/SE/"+file,["",".wav",".mp3",".ogg"])
        return RTP.getPath("Audio/SE/"+file,["",".wav",".mp3",".ogg"])
      end
      return nil
    end
    
    def pbCryFrameLength(pokemon,form=0,pitch=nil)
      return 0 if !pokemon
      pitch = 100 if !pitch
      pitch = pitch.to_f/100
      return 0 if pitch<=0
      playtime = 0.0
      if pokemon.is_a?(Numeric)
        pkmnwav = pbResolveAudioSE(pbCryFile(pokemon,form))
        playtime = getPlayTime(pkmnwav) if pkmnwav
      elsif !pokemon.egg?
        if pokemon.respond_to?("chatter") && pokemon.chatter
          playtime = pokemon.chatter.time
          pitch = 1.0
        else
          pkmnwav = pbResolveAudioSE(pbCryFile(pokemon))
          playtime = getPlayTime(pkmnwav) if pkmnwav
        end 
      end
      playtime /= pitch # sound is lengthened the lower the pitch
      # 4 is added to provide a buffer between sounds
      return (playtime*Graphics.frame_rate).ceil+4
    end

    if you could help, this would be perfect :-)
     
    Last edited by a moderator:
  • 233
    Posts
    5
    Years
    • Seen Oct 9, 2023
    If you CTRL+ Shift + F search in the script editor for the line "def pbCryFile", what search results do you get? I get this:

    def pbCryFile(pokemon,form=0)
     

    Heppy8787

    H3ppY
  • 2
    Posts
    3
    Years
    hi,

    yeah i get the same.

    but i just saw that the lines 468 to 473 look like that:
    Code:
    #  if pokemon.is_a?(Numeric)
    #    pkmnwav = pbCryFile(pokemon,form)
    #    if pkmnwav
    #      pbSEPlay(RPG::AudioFile.new(pkmnwav,volume,(pitch) ? pitch : 100)) rescue nil
    #    end
    #  end

    is this right??? looks kinda deactivated :-s

    this is the cry script i have installed:
    Code:
    #===============================================================================
    # Load/play Pokémon cry files
    #===============================================================================
    def pbPlayCry(pokemon,volume=90,pitch=nil)
      return if !pokemon
      if pokemon.is_a?(Numeric)
        pbPlayCrySpecies(pokemon,0,volume,pitch)
      elsif !pokemon.egg?
        if pokemon.respond_to?("chatter") && pokemon.chatter
          pokemon.chatter.play
        else
          pkmnwav = pbCryFile(pokemon)
          if pkmnwav
            pbSEPlay(RPG::AudioFile.new(pkmnwav,volume,
               (pitch) ? pitch : (pokemon.hp*25/pokemon.totalhp)+75)) rescue nil
          end
        end
      end
    end
    
    def pbPlayCrySpecies(pokemon,form=0,volume=90,pitch=nil)
      return if !pokemon
      if pokemon.is_a?(String) || pokemon.is_a?(Symbol)
        pokemon = getID(PBSpecies,pokemon)
      end
    #  if pokemon.is_a?(Numeric)
    #    pkmnwav = pbCryFile(pokemon,form)
    #    if pkmnwav
    #      pbSEPlay(RPG::AudioFile.new(pkmnwav,volume,(pitch) ? pitch : 100)) rescue nil
    #    end
    #  end
    end
    
    def pbCryFile(pokemon,form=0)
      return nil if !pokemon
      if pokemon.is_a?(String) || pokemon.is_a?(Symbol)
        pokemon = getID(PBSpecies,pokemon)
      end
      if pokemon.is_a?(Numeric)
        filename = sprintf("Cries/%sCry_%d",getConstantName(PBSpecies,pokemon),form) rescue nil
        if !pbResolveAudioSE(filename)
          filename = sprintf("Cries/%03dCry_%d",pokemon,form)
          if !pbResolveAudioSE(filename)
            filename = sprintf("Cries/%sCry",getConstantName(PBSpecies,pokemon)) rescue nil
            if !pbResolveAudioSE(filename)
              filename = sprintf("Cries/%03dCry",pokemon)
            end
          end
        end
        return filename if pbResolveAudioSE(filename)
      elsif !pokemon.egg?
        form = (pokemon.form rescue 0)
        filename = sprintf("Cries/%sCry_%d",getConstantName(PBSpecies,pokemon.species),form) rescue nil
        if !pbResolveAudioSE(filename)
          filename = sprintf("Cries/%03dCry_%d",pokemon.species,form)
          if !pbResolveAudioSE(filename)
            filename = sprintf("Cries/%sCry",getConstantName(PBSpecies,pokemon.species)) rescue nil
            if !pbResolveAudioSE(filename)
              filename = sprintf("Cries/%03dCry",pokemon.species)
            end
          end
        end
        return filename if pbResolveAudioSE(filename)
      end
      return nil
    end
     
    Last edited by a moderator:
  • 233
    Posts
    5
    Years
    • Seen Oct 9, 2023
    but i just saw that the lines 468 to 473 look like that:
    Code:
    #  if pokemon.is_a?(Numeric)
    #    pkmnwav = pbCryFile(pokemon,form)
    #    if pkmnwav
    #      pbSEPlay(RPG::AudioFile.new(pkmnwav,volume,(pitch) ? pitch : 100)) rescue nil
    #    end
    #  end

    is this right??? looks kinda deactivated :-s

    Hm. Try uncommenting it out and see it if works, but I don't think this part is causing the issue.

    this is the cry script i have installed:

    Your "def pbCryFile" line looks correct, so maybe it's something else. Can you post the FULL error instead of just one line? Also, if you search for "def pbCryFile" globally, how many search results do you get besides the one you just posted?
     
    Back
    Top