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.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
def pokeCheck(species)
if $Trainer.owned[PBSpecies::species]
return true
else
return false
end
end
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
Oops. My fault. Thank you for your correction.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.
Some examples of usage:Code:if $Trainer.owned[PBSpecies::Your_Pokemon]
if $Trainer.owned[PBSpecies::PIKACHU]
if $Trainer.owned[PBSpecies::MEW]
if $Trainer.owned[PBSpecies::DARKRAI]
You really don't need to use anything other than what Luka told you:
Some examples of usage:
Note the two colons.Code:if $Trainer.owned[PBSpecies::PIKACHU] if $Trainer.owned[PBSpecies::MEW] if $Trainer.owned[PBSpecies::DARKRAI]
I don't know if you're calling it right or not either. The trick is to tell us what you're trying to do, and show us what you're actually doing.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.
This isn't:Code:if $Trainer.owned[PBSpecies::DARKRAI]
Code:if $Trainer.owned[PBSpecies::@nombrepoke]
if $Trainer.owned[25]
Yes! you're right, thanks it works now but if don't have the pokemon the condition remains true.
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".check if already captured a pokemon
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)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".