Alphabetical sorting list

Okay, I don't know what I'm doing, I'm randomly shooting blanks here.

Here's how I'm going to get Pokemon for Pokemon trainers.

Harrison.Pokemonlist = NewObjectList()
list add (Harrison.Pokemonlist, Hoothoota)
list add (Harrison.Pokemonlist, Hoothootb)
StringListSort ("String list")
Getobject (result) = game.poverty.parent

Please correct me.


This is hard to answer, because it's not clear what you're actually trying to do.

I assume that you're setting Harrisson.Pokemonlist to a list of pokemon, and then you want to put that list in order.
If that's not what you're trying to do, you might need to explain what data you have, and what result you want.

You can't use StringListSort on an objectlist.

You use StringListSort on stringlists, and ObjectListSort on objectlists.

So if you want to make this list sorted, you'd do something like:

temp_list = NewObjectList()
list add (temp_list, Hoothoota)
list add (temp_list, Hoothootb)
Harrison.Pokemonlist = ObjectListSort (temp_list, "name")

You can change "name" to "alias" or whatever you want to sort them by.

But if you're always adding the same items to the list, it's easier just to put them in the right order to start with.

I have no idea what your last line is supposed to do. It's complete gibberish, and I'm not sure what you meant. Where is "result" coming from? Are you showing a menu?


Thank you for helping. It was late last night and I was tired.
So here is this.

Harrison.Pokemonlist = NewObjectList()
list add (Harrison.Pokemonlist, Hoothoota)
list add (Harrison.Pokemonlist, Hoothootb)
Harrison.Pokemon = ObjectListSort (Harrison.Pokemon list, "name")
Harrison.Pokemon.parent = game.pov.parent

So here's my battle code now...!

if (HasBoolean(object, "enemy")) {
  if (object.alias = "Harrison") {
    Harrison.Pokemonlist = NewObjectList()
    list add (Harrison.Pokemonlist, Hoothoota)
    list add (Harrison.Pokemonlist, Hoothootb)
    Harrison.Pokemon = ObjectListSort (Harrison.Pokemon list, "name")
    Harrison.Pokemon.parent = game.pov.parent
  }
  else if (object.alias = "Susan") {
    SpawnSusanHoothoot (object.parent)
  }
  else if (object.alias = "Heather") {
    SpawnHeatherHoothoot (object.parent)
  }
  else if (object.alias = "Judas") {
    SpawnJudasSentret (object.parent)
  }
  else if (object.alias = "Isabelle") {
    SpawnIsabelleSpinarak (object.parent)
  }
  else if (object.alias = "Trevor") {
    SpawnTrevorPidgey (object.parent)
  }
  else if (object.alias = "Will") {
    SpawnWillCaterpie (object.parent)
  }
  else if (object.alias = "Carmina") {
    SpawnCarminaRattata (object.parent)
  }
  else if (object.alias = "Rick") {
    SpawnRickWeedle (object.parent)
  }
  else if (object.alias = "Tobin") {
    SpawnTobinFurret (object.parent)
  }
  else if (object.alias = "Phebe") {
    SpawnIsabelleSpinarak (object.parent)
  }
  else if (object.alias = "Ito") {
    BattleBellsproutTower (object.parent)
  }
  else if (object.alias = "Junji") {
    BattleBellsproutTower (object.parent)
  }
  else if (object.alias = "Kanemaru") {
    BattleBellsproutTower (object.parent)
  }
  else if (object.alias = "Masuda") {
    BattleBellsproutTower (object.parent)
  }
  else if (object.alias = "Satoshi") {
    BattleBellsproutTower (object.parent)
  }
  else if (object.alias = "Tajiri") {
    BattleBellsproutTower (object.parent)
  }
  else if (object.alias = "Junichi") {
    BattleChiefBellsproutTower (object.parent)
    BattleChiefBellsproutTower (object.parent)
    BattleChiefBellsproutTower2 (object.parent)
  }
  else if (object.alias = "Bird Trainer Mikki") {
    SpawnTrainerHoothoot (object.parent)
  }
  else if (object.alias = "Bird Trainer Faith") {
    SpawnTrainerHoothoot (object.parent)
  }
  else if (object.alias = "Bird Trainer Adam") {
    SpawnTrainerHoothoot (object.parent)
  }
  else if (object.alias = "Bird Trainer Didier") {
    SpawnTrainerHoothoot (object.parent)
  }
  else if (object.alias = "Falkner") {
    firsttime {
      SpawnFalknerPidgeotto (object.parent)
      msg ("You start the battle!")
    }
    otherwise {
      msg ("You've already battled him before! Wait a while before rematching him!")
    }
  }
  else if (object.alias = "Bugsy") {
    firsttime {
      SpawnBugsyBeedrill (object.parent)
      msg ("You start the battle!")
    }
    otherwise {
      msg ("You've already battled him before! Wait a while before rematching him!")
    }
  }
  else if (this.alias = "Whitney") {
    firsttime {
      SpawnWhitneyClefairy (this)
      msg ("You start the battle!")
    }
    otherwise {
      msg ("You've already battled her before! Wait a while before rematching him!")
    }
  }
  else if (this.alias = "Bug Catcher Rena") {
    SpawnWillCaterpie (this)
  }
  else if (this.alias = "Bug Catcher Fredrick") {
    SpawnFredrickMetapod (this)
  }
  else if (this.alias = "Bug Catcher Alma") {
    SpawnWillCaterpie (this)
  }
  else if (this.alias = "Bug Catcher Safiyyah") {
    SpawnKakuna (this)
  }
  else if (this.alias = "Ghost Trainer Rex") {
    SpawnGastly (this)
  }
  else if (this.alias = "Ghost Trainer Michelle") {
    SpawnGastly (this)
  }
  else if (this.alias = "Ghost Trainer Rose") {
    SpawnGastly (this)
  }
  else if (this.alias = "Ghost Trainer Sara") {
    SpawnGastly (this)
  }
  else if (this.alias = "Ghost Trainer Jake") {
    SpawnMisdreavus (object.parent)
  }
  else if (this.alias = "Morty") {
    firsttime {
      SpawnMortyGengar (object.parent)
      msg ("You start the battle!")
    }
    otherwise {
      msg ("You've already battled him before! Wait a while before rematching him!")
    }
  }
  else {
    msg ("This trainer has not been worked on yet.")
  }
}
else {
  msg ("This is not a trainer!")
}

Log in to post a reply.

Support

Forums