Hello Quest people,
it hasn't been long until I encountered my next problem:
I'm trying to run this code to first filter all the objects that the player is wearing and then get just the objects that are worn in a certain slot, called "armadis"
clothes = FilterByAttribute (GetAllChildObjects (game.pov), "worn", true)
slot = FilterByAttribute (clothes, "wear_slots", "armadis")
The first line alone works, but when I add the second it does not. I think it may be because the attribute "wear_slots" is a string list and this causes some sort of error. Why is this happening? How could I solve this?
Thanks in advance and happy gaming :)
(Sorry I don't know why this was posted twice)
FilterByAttribute returns all members of an objectlist for which an attribute is equal to the specified value. So the second line would find all worn items for which their wear_stols
attribute is the string "armadis"
.
I believe wear_slots
is a stringlist, so can't be equal to a string. To do this, you'd want to loop over the list yourself and find the matching elements. So something like:
result = NewObjectList()
foreach (obj, GetAllChildObjects (game.pov)) {
if (GetBoolean (obj, "worn") and EndsWith (TypeOf (obj, "wear_slots"), "list")) {
if (ListContains (obj.wear_slots, "armadis")) {
list add (result, obj)
}
}
}