- 155
- Posts
- 10
- Years
- Seen Jun 11, 2021
So Rot8er_ConeX helped me create a script that forces you to encounter a specific Pokemon with in an event. It works well except for one problem. Once the battle ends, the game crashes with this error:
For some strange reason, it's looking for "length" in the code, but the code itself never even calls for "length" in the first place, so I don't understand why it's even looking for it. Here's the code for the method:
And here's the code used in the event script:
What am I doing wrong? This is very frustrating as I have no idea why it's searching for "length".
Spoiler:
Code:
Exception: RuntimeError
Message: Script error within event 33, map 92 (Test Map):
Exception: NoMethodError
Message: Section129:70undefined method `length' for nil:NilClass
***Full script:
poke=pbGenerateWildPokemon(PBSpecies::KROOKODILE,35)
poke.makeDelta
poke.deltatype=getConst(PBTypes,:WATER)
poke.deltatype2=getConst(PBTypes,:POISON)
pbSpecificWildBattle(poke,0)
Interpreter:243:in `pbExecuteScript'
Pokemon_ShadowPokemon:67:in `call'
Event:54:in `trigger'
Event:49:in `each'
Event:49:in `trigger'
PField_Field:982:in `pbSpecificWildBattle'
PField_Field:958:in `pbBattleAnimation'
PField_Field:958:in `pbSpecificWildBattle'
(eval):5:in `pbExecuteScript'
Interpreter:1606:in `eval'
Interpreter:276:in `pbExecuteScript'
Interpreter:1606:in `command_355'
Interpreter:494:in `execute_command'
Interpreter:193:in `update'
Interpreter:106:in `loop'
Interpreter:198:in `update'
Scene_Map:103:in `follow_update'
Scene_Map:101:in `loop'
Scene_Map:114:in `follow_update'
FollowingPokemon:1550:in `update'
Code:
def pbSpecificWildBattle(pokemon,level,variable=nil,canescape=true,canlose=false)
if (Input.press?(Input::CTRL) && $DEBUG) || $Trainer.pokemonCount==0
if $Trainer.pokemonCount>0
Kernel.pbMessage(_INTL("SKIPPING BATTLE..."))
end
pbSet(variable,1)
$PokemonGlobal.nextBattleBGM=nil
$PokemonGlobal.nextBattleME=nil
$PokemonGlobal.nextBattleBack=nil
return true
end
handled=[nil]
Events.onWildBattleOverride.trigger(nil,pokemon.species,level,handled)
if handled[0]!=nil
return handled[0]
end
currentlevels=[]
for i in $Trainer.party
currentlevels.push(i.level)
end
scene=pbNewBattleScene
battle=PokeBattle_Battle.new(scene,$Trainer.party,[pokemon],$Trainer,nil)
battle.internalbattle=true
battle.cantescape=!canescape
pbPrepareBattle(battle)
decision=0
pbBattleAnimation(pbGetWildBattleBGM(pokemon.species)) {
pbSceneStandby {
decision=battle.pbStartBattle(canlose)
}
for i in $Trainer.party; (i.makeUnmega rescue nil); end
if $PokemonGlobal.partner
pbHealAll
for i in $PokemonGlobal.partner[3]
i.heal
i.makeUnmega rescue nil
end
end
if decision==2 || decision==5 # if loss or draw
if canlose
for i in $Trainer.party; i.heal; end
for i in 0...10
Graphics.update
end
# else
# $game_system.bgm_unpause
# $game_system.bgs_unpause
# Kernel.pbStartOver
end
end
Events.onEndBattle.trigger(nil,decision,canlose)
}
Input.update
pbSet(variable,decision)
Events.onWildBattleEnd.trigger(nil,species,level,decision)
return (decision!=2)
end
Code:
poke=pbGenerateWildPokemon(PBSpecies::KROOKODILE,35)
poke.makeDelta
poke.deltatype=getConst(PBTypes,:WATER)
poke.deltatype2=getConst(PBTypes,:POISON)
pbSpecificWildBattle(poke,0)
Last edited by a moderator: