• 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] Check species AND level

3
Posts
7
Years
    • Seen Jun 14, 2016
    Hey everybody,

    how can I check if the player has a Hitmonchan with Level 40 or more in his Team?
    And can I evolve a Pokemon with an event?
     
    Last edited by a moderator:
    129
    Posts
    8
    Years
    • Seen Mar 23, 2023
    how can I check if the player has a Hitmonchan with Level 40 or more in his Team?

    Essentials has a function pbHasSpecies? which you can use to check if the player has a specific pokemon species. We can copy and modify that for your needs. (Put the following in a script section above main.)

    Code:
    def pbHasSpeciesAtLevel?(species, level)
      if species.is_a?(String) || species.is_a?(Symbol)
        species=getID(PBSpecies,species)
      end
      for pokemon in $Trainer.party
        next if pokemon.isEgg?
        return true if pokemon.species==species && pokemon.level>=level
      end
      return false
    end
    Then, you would simply be able to call pbHasSpeciesAtLevel?(:HITMONCHAN,40) from your condition.

    Note: I have not tested the above code.
     
    3
    Posts
    7
    Years
    • Seen Jun 14, 2016
    Essentials has a function pbHasSpecies? which you can use to check if the player has a specific pokemon species. We can copy and modify that for your needs. (Put the following in a script section above main.)

    Code:
    def pbHasSpeciesAtLevel?(species, level)
      if species.is_a?(String) || species.is_a?(Symbol)
        species=getID(PBSpecies,species)
      end
      for pokemon in $Trainer.party
        next if pokemon.isEgg?
        return true if pokemon.species==species && pokemon.level>=level
      end
      return false
    end
    Then, you would simply be able to call pbHasSpeciesAtLevel?(:HITMONCHAN,40) from your condition.

    Note: I have not tested the above code.

    Thanks a lot! It works perfectly!!
    Do you even know how I can start a evolution of this pokemon, when this condition came true?
     
    129
    Posts
    8
    Years
    • Seen Mar 23, 2023
    You can change Pokemon evolution methods in the pokemon.txt. No need to use scripts to do it.
     
    1
    Posts
    7
    Years
    • Seen Apr 4, 2019
    Hey, I'm new to Pokemon Essentials as well as pokecommunity. Could you tell me where exactly I paste this code and would I need to give you credit?
     
    Back
    Top