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

Type-Specific areas

6
Posts
7
Years
    • Seen Oct 23, 2017
    Hi!
    I would like to have an area where the player can only enter, if he has for example "only grass" type pokemon. Therefore i want to have some event that rejects the player if he has, in this example, a fire type. Is that possoble?

    So far i could only find this:"@>Conditional Branch: Script: pbHasSpecies?" which is close, but not what i want.
    Thank you!
     
    320
    Posts
    14
    Years
    • Seen Dec 27, 2021
    A few lines after pbHasSpecies there's is the following method pbHasType?
    This checks if the player has at least one Pokemon of a certain type in his party.
    I've made a modified version for you that returns false if the player has a Pokemon of another type than the specified one (in your case Grass)

    Code:
    def pbHasMonoType?(type)
      if type.is_a?(String) || type.is_a?(Symbol)
        type=getID(PBTypes,type)
      end
      for pokemon in $Trainer.party
        next if pokemon.isEgg?
        return false unless pokemon.hasType?(type)
      end
      return true
    end
     
    6
    Posts
    7
    Years
    • Seen Oct 23, 2017
    So... i am sorry, but i forgot how to do stuff, i started a long time ago and stopped.
    I dont know, how to use thet code now;

    i tried putting it in a conditional branche, but that only accepts 1-liners. I added spaces bewtween the "Lines", but that did not help aswell. I tried using it as a simple script (i used "grasss" instead of "type" in the code), but there also was an exception.

    Can you tell me, how to use your code? Sorry for my disability :)

    (btw. which language is the code in that game? I might just start learn it myself so i can understand more about it.)
     
    25
    Posts
    7
    Years
    • Seen Apr 20, 2017
    (btw. which language is the code in that game? I might just start learn it myself so i can understand more about it.)

    I believe it's Ruby.

    As for the code khkramer posted, it belongs in your game's script section.
    The code posted is a method you need to declare in your main script. Then you can call that part of the script from anywhere in your game.


    Open your Script Editor.
    Type-Specific areas



    Press Ctrl+Shift+F to do a global search. Search for "pbHasType".
    Double click the result. Now you'll see a section of code that defines "pbHasType".
    Beneath that block of code you'll want to paste the new code posted by khkramer.

    Like this: (the RED text is the code you need to paste)
    Code:
    def pbHasType?(type)
      if type.is_a?(String) || type.is_a?(Symbol)
        type=getID(PBTypes,type)
      end
      for pokemon in $Trainer.party
        next if pokemon.isEgg?
        return true if pokemon.hasType?(type)
      end
      return false
    end
    
    [COLOR="Red"]def pbHasMonoType?(type)
      if type.is_a?(String) || type.is_a?(Symbol)
        type=getID(PBTypes,type)
      end
      for pokemon in $Trainer.party
        next if pokemon.isEgg?
        return false unless pokemon.hasType?(type)
      end
      return true
    end[/COLOR]

    Hit 'OK' to save changes. Now you declared a new section of code to your game, but it's not being used yet.

    You use events for that. Anywhere in your game, use an event (I'm assuming you know what an event is and how they work) and place this line in a conditional branch:
    Code:
    pbHasMonoType?(:FLYING)
    ...to check if the player's party consists entirely of FLYING TYPE Pokémon.
    You can of course also use
    Code:
    pbHasMonoType?(:FIRE)
    and
    Code:
    pbHasMonoType?(:WATER)
    etc.

    The conditional branch will return true if the player only has Pokémon of that type, and false (else) if the player doesn't.

    I'm assuming the script posted by khkramer works. I haven't tested it out myself.
     
    Last edited:
    6
    Posts
    7
    Years
    • Seen Oct 23, 2017
    I believe it's Ruby.

    As for the code khkramer posted, it belongs in your game's script section.
    The code posted is a method you need to declare in your main script. Then you can call that part of the script from anywhere in your game.


    Open your Script Editor.
    Type-Specific areas



    Press Ctrl+Shift+F to do a global search. Search for "pbHasType".
    Double click the result. Now you'll see a section of code that defines "pbHasType".
    Beneath that block of code you'll want to paste the new code posted by khkramer.

    Like this: (the RED text is the code you need to paste)
    Code:
    def pbHasType?(type)
      if type.is_a?(String) || type.is_a?(Symbol)
        type=getID(PBTypes,type)
      end
      for pokemon in $Trainer.party
        next if pokemon.isEgg?
        return true if pokemon.hasType?(type)
      end
      return false
    end
    
    [COLOR="Red"]def pbHasMonoType?(type)
      if type.is_a?(String) || type.is_a?(Symbol)
        type=getID(PBTypes,type)
      end
      for pokemon in $Trainer.party
        next if pokemon.isEgg?
        return false unless pokemon.hasType?(type)
      end
    return true[/COLOR]

    Hit 'OK' to save changes. Now you declared a new section of code to your game, but it's not being used yet.

    You use events for that. Anywhere in your game, use an event (I'm assuming you know what an event is and how they work) and place this line in a conditional branch:
    Code:
    pbHasMonoType?(:FLYING)
    ...to check if the player's party consists entirely of FLYING TYPE Pokémon.
    You can of course also use
    Code:
    pbHasMonoType?(:FIRE)
    and
    Code:
    pbHasMonoType?(:WATER)
    etc.

    The conditional branch will return true if the player only has Pokémon of that type, and false (else) if the player doesn't.

    I'm assuming the script posted by khkramer works. I haven't tested it out myself.

    Wow, that was easy enough for me :)
    My problem now is that i use a modified version of pokemon essentials (some methods are changed.)
    The error i get is a "NoMethodError". I already fixed the missing "end" in your quote.
    The pbHasType?(type) method looks like this:

    def pbHasType?(type)
    if type.is_a?(Symbol) || type.is_a?(String)
    ret=isConst?(self.type1,PBTypes,type.to_sym) ||
    isConst?(self.type2,PBTypes,type.to_sym)
    return ret
    else
    return (self.type1==type||self.type2==type)
    end
    end

    I would be pleased if you or someone elso could try to modify that code.

    Btw. i am using the "pokemon omicron" game, it that matters.

    Thank you very much!
     
    971
    Posts
    7
    Years
    • Age 21
    • Seen Nov 28, 2022
    Wow, that was easy enough for me :)
    My problem now is that i use a modified version of pokemon essentials (some methods are changed.)
    The error i get is a "NoMethodError". I already fixed the missing "end" in your quote.
    The pbHasType?(type) method looks like this:

    def pbHasType?(type)
    if type.is_a?(Symbol) || type.is_a?(String)
    ret=isConst?(self.type1,PBTypes,type.to_sym) ||
    isConst?(self.type2,PBTypes,type.to_sym)
    return ret
    else
    return (self.type1==type||self.type2==type)
    end
    end

    I would be pleased if you or someone elso could try to modify that code.

    Btw. i am using the "pokemon omicron" game, it that matters.

    Thank you very much!

    When you post code, it's useful to put [ CODE ] before the code (without spaces) and [ /CODE ] (no spaces) after to keep the formatting.

    It would probably look something like (This is for other people who want to help you):
    Code:
      def pbHasType?(type)
        if type.is_a?(Symbol) || type.is_a?(String)
          ret=isConst?(self.type1,PBTypes,type.to_sym) ||
             isConst?(self.type2,PBTypes,type.to_sym)
          return ret
        else
          return (self.type1==type||self.type2==type)
        end
      end
     
    Back
    Top