Good way to compare and modify lists with objects?

TinFoilMkIV
21 Nov 2016, 20:33Currently I'm trying to compare two lists and build a third list of any non-matching objects. The issue being that some of the objects in the second list are clones so can't be directly compared. Ultimately I need to return back to an object which is where I was running into trouble, since I can convert the lists to aliases to get a match across clones, but not sure how to convert that back into the original object. Or if there's a better method to accomplish this.
More detailed description of the scenario:
-There is a master container outside the game area holding a single copy of each item to be used.
-When an item is obtained it is cloned and given to the character getting it.
-there is a case where I want to pull from a list of items without granting a duplicate
-two lists are created, one of possible items, one of items to not be duplicated
-a 3rd list will be created based on the previous two of all allowed items, which will then be selected from
Current issues:
-due to cloned items, neither the objects or their names can be directly compared
-quest doesn't seem to like removing items from a list inside two 'foreach' cycles in an attempt to manually compare lists
-can convert lists to a comparable string, but not sure how to get back to an object afterwards.
-While there is a finite number of copies that will be allowed to exist in the game at any given time, the ammount would be very unwieldy to generate and handle manually.
The Pixie
21 Nov 2016, 22:51If you are finding an object by its alias and there are several clones, how will you know if you have the right one?
If there is only one or you do not care which, do this inside a function that returns an object:
foreach (o, AllObjects()) {
if (HasString(o, "alias")) {
if (o.alias = search_alias) {
return (o)
}
}
}
return (null)
You could adapt that to look in a certain room using a Scope
function.
Make sure all the relevant objects have aliases right from the start.
Not sure if this will quite do, but this will compile a list of objects that is in the object list, but whose alias is not in the second list.
result = NewObjectList()
foreach (o, objectlist) {
if (not ListContains(aliaslist, o.alias) {
list add(result, o)
}
}
-quest doesn't seem to like removing items from a list inside two 'foreach' cycles in an attempt to manually compare lists
I do not think it likes you doing that inside one.

TinFoilMkIV
21 Nov 2016, 23:24In the cases where I need this code there should never be more than one copy of an object being checked, since the original is being pulled from a preset list and being compared to items held by a character. And if the code functions, it shouldn't be possible for that character to obtain more than one clone of an object.
At the moment I'm using GetDirectChildren to build the second list and comparing that to the preset one.
I suspect the solution I'm looking for is in here somewhere, I'll have to do more testing.
I would have preferred if I could copy my master list and just remove items from the temporary copy if they fail the check, but seems like I'll have to do it in reverse.