The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Creative Discussions > Game Development > Pokémon Essentials
Sign Up Rules/FAQ Live Battle Blogs Mark Forums Read

Notices

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
Click here to go to the first staff post in this thread.  
Thread Tools
  #1    
Old December 24th, 2013, 01:35 PM
Franzo's Avatar
Franzo
 
Join Date: Mar 2008
Gender: Male
Nature: Modest
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
Lead Dev of Pokémon Essentials
 
Join Date: Jan 2008
Location: England
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
 
Join Date: Mar 2008
Gender: Male
Nature: Modest
Yep, that did it. I see what I did wrong.
Thank you very much!
Reply With Quote
Reply
Quick Reply

Sponsored Links
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
Minimum Characters Per Post: 25



All times are UTC -8. The time now is 11:51 PM.


Style by Nymphadora, artwork by Sa-Dui.
Like our Facebook Page Follow us on Twitter © 2002 - 2014 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2014 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.