Preventing multiple entries of the same item in a string list
Curt A. P.
02 Aug 2018, 21:52I'm working on kinda dynamic conservations with NPCs.
There are multiple ways to get the new option for certain conversations and I need a way to check the list beforehand.
If a conversation option already exists it'll be listed twice like now. Adding something just for the first time doesn't help, because it could be triggered somewhere else.
My conversation options are retrieved from a string list for each step of the conversation. If the player gets certain knowledge, the option is added to a list.
For the adding step, I was hoping for something like: If list does not contain "BlaBla." then add "Blabla."
mrangel
02 Aug 2018, 22:54if (not ListContains (someobject.listattribute, "Some option")) {
list add (someobject.listattribute, "Some option")
}
You might also find ListCompact() useful. The statement someList = ListCompact (someList)
will remove all duplicates from a list.
Curt A. P.
02 Aug 2018, 23:04Thanks, it seems the 'ListCompact' function is the most easiest way to implant into my already existing conversations.