• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Which Pokémon Masters protagonist do you like most? Let us know by casting a vote in our Masters favorite protagonist poll here!
  • Red, Hilda, Paxton, or Kellyn - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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.

[Scripting Question] Scripting tips

  • 40
    Posts
    4
    Years
    • Seen Jan 13, 2022
    I am trying to get a script working, but I keep running into issues with the new sub-category of isSpecies?
    If anyone can help, much appreciated. Code below.
    Code:
    def pbCelelocus
      def isDeterminedSpecies?(species,level)
        return @pokemon && @pokemon.isDeterminedSpecies?(species,level)
      end
      
      if isDeterminedSpecies?(:SOLROCK,40) && 
         isDeterminedSpecies?(:LUNATONE,40)
        pbMessage(_INTL("The experiment is beginning.\nHand over the sun and moon, please."))
        pbRemovePokemonAt(1)
        pbRemovePokemonAt(2)
        pbMessage(_INTL("The experiment worked. Here is your new Pokemon!"))
        pbAddPokemon(:CELELOCUS,40)
      else
        pbMessage(_INTL("Come back when you are ready, then."))
      end
    end
     
    There are a lot of syntax issues with your script. Since you're trying to script things on your own, you should try to actually learn the basics of how to do so. Marin has a good Ruby tutorial here: (broken link removed).

    It looks like you're trying to make a function to combine a level 40 Solrock and Lunatone into a new Pokemon Celelocus. The only thing I'm confused about is how the player chooses which 2 Pokemon from the party in the first place? It looks like you are just assuming the first two spots of the party should have the Solrock and Lunatone. In most programming languages, though, arrays or lists start at index 0, so the first two spots would actually be 0 and 1, not 1 and 2. Also, "pbRemovePokemonAt" fails if it's trying to remove the player's last unfainted Pokemon. This means that if the player tries to combine when they have ONLY Solrock and Lunatone in their party, and nothing else, the Lunatone will just stay in the party.

    You can try rewriting your function like so:

    Code:
    def pbCelelocus
      poke1 = $Trainer.party[0]
      poke2 = $Trainer.party[1]
      # First must be Solrock, second must be Lunatone
      if poke1.level == 40 && poke2.level == 40 && poke1.isSpecies?(:SOLROCK) && poke2.isSpecies?(:LUNATONE) && !poke1.egg? && !poke2.egg?
        pbMessage(_INTL("The experiment is beginning.\nHand over the sun and moon, please."))
        $Trainer.party.delete_at(0)
        $Trainer.party.delete_at(0) # The Pokemon that used to be second is now first
        pbMessage(_INTL("The experiment worked. Here is your new Pokemon!"))
        pbAddPokemon(:CELELOCUS,40)
      else
        pbMessage(_INTL("Come back when you are ready, then."))
      end
    end
     
    Back
    Top