• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Conquest protagonist in the poll by clicking here.
  • 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.

Check if a pokemon species is owned

mane

I need more class of English:/
  • 17
    Posts
    14
    Years
    Hello, I think my question is simple.
    how do a script to check if already captured a pokemon, I need it in a script not in an event.
    As I need it in several parts, because it'll contain another script.
     
    Thanks for answer, It appears that there is a syntax error in the part of the if
    Code:
    class Poke_check
      def initialize(nombrepoke)
        @nombrepoke=nombrepoke
      end
      def check
        if $Trainer.owned[PBSpecies::@nombrepoke]
          Kernel.pbMessage(_INTL("text"))
        else
          Kernel.pbMessage(_INTL("another text"))
        end
      end
    end
     
    Thanks for answer, It appears that there is a syntax error in the part of the if
    Code:
    class Poke_check
      def initialize(nombrepoke)
        @nombrepoke=nombrepoke
      end
      def check
        if $Trainer.owned[PBSpecies::@nombrepoke]
          Kernel.pbMessage(_INTL("text"))
        else
          Kernel.pbMessage(_INTL("another text"))
        end
      end
    end
    You don't need to create a class, but you can make a simple function (def). The error is due to the fact that you have to use the name of a Pokemon in species format, not in string format.

    Code:
    def pokeCheck(species)
      if $Trainer.owned[PBSpecies::species]
          return true
        else
          return false
      end
    end
    To use this, do as follow:
    [PokeCommunity.com] Check if a pokemon species is owned
     
    Code:
    def pokeCheck(species)
      if species.is_a?(String) || species.is_a?(Symbol)
        species=getConst(PBSpecies,species)
      end
      if $Trainer.owned[species]
          return true
        else
          return false
      end
    end

    "Species" is not a constant in the PBSpecies class.
     
    Code:
    def pokeCheck(species)
      if species.is_a?(String) || species.is_a?(Symbol)
        species=getConst(PBSpecies,species)
      end
      if $Trainer.owned[species]
          return true
        else
          return false
      end
    end

    "Species" is not a constant in the PBSpecies class.
    Oops. My fault. Thank you for your correction.
     
    You really don't need to use anything other than what Luka told you:

    Code:
    if $Trainer.owned[PBSpecies::Your_Pokemon]
    Some examples of usage:

    Code:
    if $Trainer.owned[PBSpecies::PIKACHU]
    if $Trainer.owned[PBSpecies::MEW]
    if $Trainer.owned[PBSpecies::DARKRAI]
    Note the two colons.
     
    You really don't need to use anything other than what Luka told you:


    Some examples of usage:

    Code:
    if $Trainer.owned[PBSpecies::PIKACHU]
    if $Trainer.owned[PBSpecies::MEW]
    if $Trainer.owned[PBSpecies::DARKRAI]
    Note the two colons.

    Yes, but I get the same error, I don't know if I called it right or not.
     
    As I put at the beginning I try to make a system to check if certain conditions are met and if you have some pokemon in your team can appear an object or pokemon.
     
    As I put at the beginning I try to make a system to check if certain conditions are met and if you have some pokemon in your team can appear an object or pokemon.

    You need to brush up on your knowledge of how to use Symbols then.

    This is the proper way to use them:
    Code:
    if $Trainer.owned[PBSpecies::DARKRAI]
    This isn't:
    Code:
    if $Trainer.owned[PBSpecies::@nombrepoke]

    Or if this is proving too difficult, you can just use the species number (i.e. 25) instead of the species symbol (i.e. :PIKACHU).
    Spoiler:
     
    Yes! you're right, thanks it works now but if don't have the pokemon the condition remains true.
     
    Yes! you're right, thanks it works now but if don't have the pokemon the condition remains true.
    check if already captured a pokemon
    This is what you asked for. $Trainer.owned does exactly that. It checks if you captured a Pokemon (at least once), and keeps the record of that just like you'd see in the Pokedex. It doesn't keep track of whether or not you are still in possession of the Pokemon. It keeps track of whether or not you have once captured (i.e. been in the possession) of the Pokemon. If you're debugging to fill your boxes, you'll have all the Pokemon as "owned".
     
    This is what you asked for. $Trainer.owned does exactly that. It checks if you captured a Pokemon (at least once), and keeps the record of that just like you'd see in the Pokedex. It doesn't keep track of whether or not you are still in possession of the Pokemon. It keeps track of whether or not you have once captured (i.e. been in the possession) of the Pokemon. If you're debugging to fill your boxes, you'll have all the Pokemon as "owned".
    Hello, so I just posted a similar question with the complete coding of what I've put, I'm not sure what I've done wrong (I've used the $trainer.owned code but can't seem to make it work)
     
    Back
    Top