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

[Scripting Question] Get opponents first pokemon species

  • 6
    Posts
    6
    Years
    Hello, I need to know the first pokemon of an opponent BEFORE the battle.
    How could I do it?
    Thanks
     
    I found a roundabout way searching in the PBS file:

    def pkm_trainer(type,name)

    pkm=0
    list=File.new "\PBS\\trainers.txt"
    content=list.readlines
    list.close

    i=0
    while i <=content.length-1
    if content==type+"\n" && content[i+1]==name+"\n"
    pkm=content[i+3]
    i=content.length
    end
    i+=1
    end
    end

    Being type the trainertype ("HIKER") and name the trainer`s name and possible versions ("Mary")/("Mary,2"), although for that last one you should include this:
    if pkm.is_a?(String) && pkm.include?(",")
    pkm=pkm.split (",") [0]
    end

    The result will be the Interal name of the first pkm of that trainer.
    I'm sure there is a more direct way
     
    Back
    Top