Page 1 of 1

FindSubstance array

Posted: Sat Aug 02, 2008 5:25 am
by OldnGrey
When I use FindSubstance, a successful return array always has just one itemref in it.

From my reading of the documentation, shouldn't it be returning an array of all found itemrefs in the container that equals or exceeds the amount you specify. Or is that just my wrong reading of it? I don't see why it would be returning an array if it stops looking after it finds the first match.

Posted: Sat Aug 02, 2008 6:57 am
by CWO
I think it fills the array until it at least satisfies the amount you want. Like what if you want an item that doesn't stack but you want 5 of them. The array should now have 5 elements if the container has all 5 items in it.

Posted: Sat Aug 02, 2008 6:04 pm
by OldnGrey
That's a nuisance - it would be so handy to let the script choose which one from an array of matches. I hate to use EnumerateItemsInContainer but it seems I will have to do it to get what I need.

Posted: Sun Aug 03, 2008 1:11 am
by ncrsn
OldnGrey, why would you need it? I'm just curious, I don't have a polished solution to offer.

Posted: Sun Aug 03, 2008 5:00 am
by OldnGrey
Sometimes my ingredients in crafting are non-stackable items that can have cprops or colours depending on their use in the game. I don't want to use an ingredient in crafting if it is marked for some other use.

FindSubstance has no way to find a match except by starting container, objtype and amount.

If I'd known of the a while ago I would have coded items differently!