def pbHasPokemonType?(type)
if type.is_a?(String) || type.is_a?(Symbol)
type=getID(PBTypes,type)
end
for pokemon in $Trainer.party
next if pokemon.isEgg?
return true if pokemon.hasType?(type)
end
return false
end
I'm trying to use your script in my project but it's not working, dose it still work in v21.1 or am I doing something wrong?
$player.has_pokemon_of_type?(:NORMAL)
Thank you! But what if I want to only read the first type of a Pokemon? e.g. Gloom = GRASS & POISON, so the NPC will only say or do the thing coz of the GRASS typing.Code:$player.has_pokemon_of_type?(:NORMAL)
This returns true if there is a Pokémon in the player's party of the specified type, false if there is no such Pokémon in the party or if the specified type doesn't exist.
Thank you! But what if I want to only read the first type of a Pokemon? e.g. Gloom = GRASS & POISON, so the NPC will only say or do the thing coz of the GRASS typing.
# checks whether party contains at least one Pokémon of some specified primary type
def checkPrimaryType(targettype)
$player.party.each do |pkmn|
primarytype = pkmn.types[0]
return true if primarytype == targettype
end
return false
end
OH WOW!! Thank you, I'll try it out and report back. You've very kind :)I don't know of a ready-made method that checks the player's party for a specific primary type. But you could try inserting this custom script into the script editor:
Ruby:# checks whether party contains at least one Pokémon of some specified primary type def checkPrimaryType(targettype) $player.party.each do |pkmn| primarytype = pkmn.types[0] return true if primarytype == targettype end return false end
Example:
checkPrimaryType(:NORMAL) would return true if there is at least one Pokémon in the party with a primary typing of NORMAL, and false in all other circumstances.