- 30
- Posts
- 300
- Days
- Seen Jun 8, 2025
I found this code that let's me change a pokemon's ability. The only problem is that when the player presses B it crashes the game. (other than that the code works great!
------------------------------------------------------------------------------------------------
def pbChangeChoose
pbChoosePokemon(1,3)
pkmn=$Trainer.party[$game_variables[1]] if $game_variables[1] >= 0
if pkmn
options = pkmn.getAbilityList.map { |ability, _| GameData::Ability.get(ability).name }
choice = pbMessage("What ability to you want?",options,options[pkmn.ability_index])
pkmn.ability_index = choice
end
end
--------------------------------------------------------------------------------------------------
The Error
comparison of String with 0 failed
--------------------------------------------------------------------------------------------------
I tried adding a branch in the case where choice = 0 or nil, but it didn't work.
------------------------------------------------------------------------------------------------
def pbChangeChoose
pbChoosePokemon(1,3)
pkmn=$Trainer.party[$game_variables[1]] if $game_variables[1] >= 0
if pkmn
options = pkmn.getAbilityList.map { |ability, _| GameData::Ability.get(ability).name }
choice = pbMessage("What ability to you want?",options,options[pkmn.ability_index])
pkmn.ability_index = choice
end
end
--------------------------------------------------------------------------------------------------
The Error
comparison of String with 0 failed
--------------------------------------------------------------------------------------------------
I tried adding a branch in the case where choice = 0 or nil, but it didn't work.