• 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.

Checking a player's egg for its species?

91
Posts
14
Years
    • Seen Sep 5, 2015
    What's the script to check for the species of an Egg? I tried the following:

    "pbHasSpecies?(:SPECIES)" would do the trick, but Eggs are not considered as species when not born.
    "$Trainer.party[0].egg?" only returns whether that Pokemon is an Egg or not, but doesn't check species.
    "pbHasEgg?(:SPECIES)" simply returns true if the species targetted can breed or be bred.

    Im doing a Game Corner Egg Store with coins. I want the player to be able to choose a "Mysterious Egg" among other species. When choosing the Mysterious Egg (which is simply a Caterpie) then I want to check for the Species (so it's not any of the other possible species) so if it IS Caterpie, then I change its species, change moves, make shiny, change steps...

    I can already purchase eggs with no problem, but the problem comes in checking the egg bought in order to change it if it's the special one.

    Script looks like this:
    Spoiler:

    Then of course check if the party is full etc. That part is working well so no problem with that.

    I know I should be looking at the code in the purchase script (pbSet) as it's storing the species into a variable, but when using $game_variables[1]=:CATERPIE the conditional branch is completely ignored (doesn't even go to Else).

    Clueless. Hope someone with more knowledge can help me learn.
     
    Last edited:
    1,224
    Posts
    10
    Years
  • A simple edit to pbHasSpecies will do the trick

    Code:
    def pbHasSpecies?(species[COLOR="Red"],ignoreeggs=true[/COLOR])
      if species.is_a?(String) || species.is_a?(Symbol)
        species=getID(PBSpecies,species)
      end
      for pokemon in $Trainer.party
        next if pokemon.isEgg? [COLOR="red"]&& ignoreeggs[/COLOR]
        return true if pokemon.species==species
      end
      return false
    end
     
    91
    Posts
    14
    Years
    • Seen Sep 5, 2015
    A simple edit to pbHasSpecies will do the trick

    Code:
    def pbHasSpecies?(species[COLOR="Red"],ignoreeggs=true[/COLOR])
      if species.is_a?(String) || species.is_a?(Symbol)
        species=getID(PBSpecies,species)
      end
      for pokemon in $Trainer.party
        next if pokemon.isEgg? [COLOR="red"]&& ignoreeggs[/COLOR]
        return true if pokemon.species==species
      end
      return false
    end
    It does! Problem is, if the player actually has the Pokémon inside the "mysterious egg", problems arise, but I'm just going an unobtainable Pokémon for the Egg. Thank you.
     
    91
    Posts
    14
    Years
    • Seen Sep 5, 2015
    Edit: Don't tell me it's the "egg?" and "isEgg?" thing lol... Yes it is... Now I have YET another problem.
    Edit2: All working! Apparently I really didn't have def lastparty in my scripts... Weird.
     
    Last edited:

    Maruno

    Lead Dev of Pokémon Essentials
    5,286
    Posts
    16
    Years
    • Seen May 3, 2024
    Purchase script:
    Code:
    item=[:BULBASAUR,:CHARMANDER,
          :SQUIRTLE,:MEOWTH,
          :CATERPIE,0][pbGet(1)]
    price=[30,30,30,15,20,
           0][pbGet(1)]
    lv=[9,8,18,25,26,0][pbGet(1)]
    if item && item!=0
      item=getID(PBSpecies,item)
    end
    pbSet(1,item); pbSet(2,price)
    pbSet(3,PBSpecies.getName(item))
    pbSet(4,lv)
    You already HAVE the species of the egg. It's stored in Variable 1. Get it with pbGet(1). Compare it to Caterpie with pbGet(1)==PBSpecies::CATERPIE. Note the double equals signs.
     
    Back
    Top