• 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] Crash during wild battles (item related?)

4
Posts
5
Years
  • Age 26
  • Seen Feb 17, 2023
Hey!

So, my project started to crash whenever I try to start a Wild Battle. Those are the logs:

Exception: NoMethodError
Message: undefined method `length' for nil:NilClass
PItem_Bag:101:in `pbQuantity'
PItem_Bag:106:in `pbHasItem?'
PField_Encounters:345:in `pbGenerateWildPokemon'
PField_Battles:88:in `pbWildBattle'
Debug_Menu:301:in `pbDebugMenuActions'
Debug_Menu:744:in `pbDebugMenu'
Debug_Menu:710:in `loop'
Debug_Menu:746:in `pbDebugMenu'
PScreen_PauseMenu:251:in `pbStartPokemonMenu'
PScreen_PauseMenu:250:in `pbFadeOutIn'

I did change some lines in both PItem_Bag and Settings, but I just can't see what's making it crash... What should I do?

Of course, you can see the scripts here:

PItem_Bag
Spoiler:


Settings:
Spoiler:

Thanks!
 
1,403
Posts
9
Years
  • Seen yesterday
What's on line 101? When you read an error message start from the top, the first thing mentioned is the line of code that's crashing (the next line is the code that called the crashing code, and so on).

I'm assuming it's this line of code:
Code:
maxsize = @pockets[pocket].length if maxsize<0
Which suggests that you've got an invalid pocket defined for your item (and thus that @pockets[pocket] is nil, and thus nil.length gives you the error: "undefined method `length' for nil:NilClass").
 
4
Posts
5
Years
  • Age 26
  • Seen Feb 17, 2023
What's on line 101? When you read an error message start from the top, the first thing mentioned is the line of code that's crashing (the next line is the code that called the crashing code, and so on).

I'm assuming it's this line of code:
Code:
maxsize = @pockets[pocket].length if maxsize<0
Which suggests that you've got an invalid pocket defined for your item (and thus that @pockets[pocket] is nil, and thus nil.length gives you the error: "undefined method `length' for nil:NilClass").

Thanks. I already got what happened. Since I reduced the number of pockets in the bag, it was checking items.txt and giving me that error, since some of the items there were on bags that did not exist anymore. I thought it only checked once said item was received or used.
 
Back
Top