- 288
- Posts
- 6
- Years
- Seen Feb 3, 2025
Hi, so I'm using a Pokebattle_AI script with over 40,000 lines of code. However, I'm having trouble tracing the error messages that pop up, and I was wondering how I'm supposed to figure out what line the problem is actually on (or at least narrow it down to like 5 possibilities) because the line numbers for the error messages have only 4 digits. For example, I'm getting the following error message:
The first line in the error message correctly identifies the location because the line number with a problem is actually 23. However, I need to trace the problem further back because I'm not sure what the input to pbGetMoveScore was. For some reason, if I make a syntax error or something that the compiler catches before successfully launching the game, it gives the correct line number even if that line is over 10000. One would assume when it says "PokeBattle_AI:7838:in `pbShouldSwitch?'" that maybe the actual line it refers to is either 7838, 17838, 27838, or 37838 because in the actual script editor, each of these lines are also displayed as 7838. However none of those lines call pbGetMoveScore (here are these lines with the code on them):
Also, the pbShouldSwitch? method spans from lines 39727 to 40696, so there is not even a line in that method that would display as 7838. Does anyone know how the error recalculates this line number so maybe I can figure out a way to calculate it back on my own? I suppose in this situation I could just search for every call to pbGetMoveScore in pbShouldSwitch?, but it gets really annoying with error messages that have like 50 calls to a certain method within a different method.
Spoiler:
Code:
[Pokémon Essentials version 17.2]
Exception: NoMethodError
Message: undefined method `<' for nil:NilClass
PokeBattle_AI:23:in `pbGetMoveScore'
PokeBattle_AI:7838:in `pbShouldSwitch?'
PokeBattle_AI:7810:in `each'
PokeBattle_AI:7810:in `pbShouldSwitch?'
PokeBattle_AI:2087:in `pbDefaultChooseEnemyCommand'
PokeBattle_Scene:3216:in `pbChooseEnemyCommand'
PokeBattle_Battle:4083:in `pbCommandPhase'
PokeBattle_Battle:4078:in `each'
PokeBattle_Battle:4078:in `pbCommandPhase'
PokeBattle_Battle:4019:in `pbStartBattleCore'
Spoiler:
Code:
7838: end
17838: if @aiMoveMemory[1].length>0
27838: if attacker.hp==attacker.totalhp && attacker.hasWorkingItem(:FOCUSSASH)
37838: fieldscore*=0.8