Go Back   The PokéCommunity Forums > Creative Discussions > Game Development > Pokémon Essentials
Reload this Page [Question] Checking the team for a certain type

Notices
For all updates, view the main page.

Pokémon Essentials All questions and discussion about Pokémon Essentials, the Pokémon game kit for RPG Maker XP, go in here. Also contains links to the latest downloads and the Essentials Wiki.



Reply
 
Thread Tools
  #1    
Old December 24th, 2013 (01:35 PM).
Franzo's Avatar
Franzo Franzo is offline
Developing something...
 
Join Date: Mar 2008
Location: England
Gender: Male
Nature: Modest
Posts: 51
Like the pbHasSpecies?(:BULBASAUR), I wanted to make a function that checks the team for a certain type.

I added this in PokemonUtilities:

Quote:
def pbHasType?(types) # Searches team for certain type
if types.is_a?(String)
types=getID(PBTypes,types)
end
for pokemon in $Trainer.party
next if pokemon.egg?
return true if pokemon.getID(PBTypes,types)==types
end
return false
end
I made a test event. it's page has this in it:

Quote:
Conditional Branch: Script: pbHasType?(:BUG)
Text: BUG type in team.

else

Text: No BUG type in team.

Branch End
But whatever pokémon I have in the party, it always says "No BUG type in team." I'm pretty sure the Utitlities code is incorrect but i'm not very experienced with Ruby. Any help?
Reply With Quote
  #2    
Old December 24th, 2013 (03:11 PM).
Maruno's Avatar
Maruno Maruno is online now
Lead Dev of Pokémon Essentials
Moderator
 
Join Date: Jan 2008
Location: England
Posts: 4,552
The line where you check the type of each Pokémon in the party is definitely incorrect. Use this:

Code:
def pbHasTypeInParty?(type)
  if type.is_a?(String) || type.is_a?(Symbol)
    return false if !hasConst?(PBTypes,type)
    type=getID(PBTypes,type)
  end
  for pokemon in $Trainer.party
    next if pokemon.egg?
    return true if pokemon.hasType?(type)
  end
  return false
end
The method name is different and more descriptive. There's also a check to make sure you're looking for a type that exists - without this check, any non-existent type would be treated as type 0 (Normal). It's there for completeness.
__________________
Reply With Quote
  #3    
Old December 24th, 2013 (03:28 PM).
Franzo's Avatar
Franzo Franzo is offline
Developing something...
 
Join Date: Mar 2008
Location: England
Gender: Male
Nature: Modest
Posts: 51
Yep, that did it. I see what I did wrong.
Thank you very much!
__________________
Pokémon Delta Emerald
Reply With Quote
Reply
Quick Reply

Sponsored Links

You may also like.. (Beta)
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are UTC -8. The time now is 05:56 AM.