• 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.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Cyndy, May, Hero (Conquest), or Wes - 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.

[Other Question] ¿Cómo puedo eliminar todos los pokemon menos uno?

  • 11
    Posts
    4
    Years
    • Seen Sep 12, 2020
    Perdón por mi idioma, pero es que no hablo inglés aunque sí lo entiendo. Llevo dos días intentando crear un mecanismo para eliminar todos los pokemon de mi equipo excepto una especie determinada, pero no lo he conseguido, realmente es muy difícil. Quiero saber si alguno de ustedes sabe cómo. He encontrado un script que hace algo parecido y es el siguiente:
    def deleteSpecies(species)
    for i in 0...$Trainer.pokemonParty.length
    if ($Trainer.pokemonParty!=nil) && ($Trainer.pokemonParty.species == species)
    pbRemovePokemonAt(i)
    end
    end
    end
    Este script elimina todos los pokemon de una determinada especie y yo quiero que haga lo contrario, es decir quiero que elimine todos los pokemon menos la especie seleccionada ¿Alguien sabe cómo modificar este script para que haga eso? Gracias.
     
    Yo no hablo Espanol, pero comprendo un poco. I will speak in English to explain better, though. First, "$Trainer.pokemonParty" and "$Trainer.party" are different arrays, and "pbRemovePokemonAt" works on "$Trainer.party", so use that. You don't need to check "$Trainer.party!=nil" unless you want to, but the array won't ever have nil spaces if you're careful. As for "pbRemovePokemonAt", the problem in your current loop is that if it deletes a certain Pokemon, it does NOT check the Pokemon after it at all, so you need to backtrack one space after removing a Pokemon. Finally, regarding your actual question, just change from "==" to "!=". I believe this code should work:
    Code:
    def deleteSpecies(species)
      i = 0
      while i < $Trainer.party.length
        if $Trainer.party[i].species != species && pbRemovePokemonAt(i)
          i -= 1
        end
        i += 1
      end
    end
     
    Wow! Muchas gracias!! Es justo lo que necesitaba, el scrip funciona perfectamente ¡Te daré créditos cuando termine mi proyecto!
     
    Back
    Top