• 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!
  • 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.

[Error] undefined method `-' for nil:NilClass

  • 71
    Posts
    5
    Years
    So I added some new encounters that I had in my previous 17.2 version (Honey, BerryTree and DarkGrass) and so I placed my encounters.txt on this pbs 18.1 Essentials.

    Now I get this all the time

    Spoiler:


    Using the Vanilla Encounters from 18.1 doesn't fix it, either deleting the save file. As far I'm concerned, I haven't seen anyone with this error, so idk what to do to fix it
     
    So, the code raising the error is:
    Code:
        elsif needdensity
          needdensity = false
          nums = strsplit(line,/,/)
          if nums && nums.length>=3
            for j in 0...EncounterTypes::EnctypeChances.length
              next if !EncounterTypes::EnctypeChances[j] ||
                      EncounterTypes::EnctypeChances[j].length==0
              next if EncounterTypes::EnctypeCompileDens[j]==0
              thisenc[0][j] = nums[EncounterTypes::EnctypeCompileDens[j]-1].to_i # Here
            end
          else
            raise _INTL("Wrong syntax for densities in encounters.txt; got \"{1}\"\r\n{2}",line,FileLineData.linereport)
          end
          i += 1

    The error says that EncounterTypes::EnctypeCompileDens[j] is nil, which happens if j is beyond the allowed indices (probably just 13 of something like that).

    Find the module EncounterTypes and compare it with this one; my guess is that EnctypeChances is longer than EnctypeCompileDens in your code.
    Spoiler:
     
    So, the code raising the error is:
    Code:
        elsif needdensity
          needdensity = false
          nums = strsplit(line,/,/)
          if nums && nums.length>=3
            for j in 0...EncounterTypes::EnctypeChances.length
              next if !EncounterTypes::EnctypeChances[j] ||
                      EncounterTypes::EnctypeChances[j].length==0
              next if EncounterTypes::EnctypeCompileDens[j]==0
              thisenc[0][j] = nums[EncounterTypes::EnctypeCompileDens[j]-1].to_i # Here
            end
          else
            raise _INTL("Wrong syntax for densities in encounters.txt; got \"{1}\"\r\n{2}",line,FileLineData.linereport)
          end
          i += 1

    The error says that EncounterTypes::EnctypeCompileDens[j] is nil, which happens if j is beyond the allowed indices (probably just 13 of something like that).

    Find the module EncounterTypes and compare it with this one; my guess is that EnctypeChances is longer than EnctypeCompileDens in your code.
    Spoiler:
    It was that and I managed to fixed it! Thank you so much!!! <3
     
    Back
    Top