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

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

71
Posts
4
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
     

    StCooler

    Mayst thou thy peace discover.
    9,301
    Posts
    4
    Years
    • Seen May 5, 2024
    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:
     
    71
    Posts
    4
    Years
  • 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