We can have a Formlist of Formlists? Nice! I was so disappointed when I found that we couldn't have nested arrays.
An FLST can contain any form, but the constituent FLSTs' members aren't seen if checking such an FLST of FLSTs, unfortunately. Still useful for nested While loops...
@Justin, in the inner loop where at least one item has been found to be equipped, it will probably speed it up if you could filter out the equipped items from the full list and do a bulk RemoveItem() on most of the weapons on the list in one go. Even if you had to use an empty tempformlist just used for this purpose. It's probably the UI having to be updated (and blinking) that is causes most of the lag.
Watching this to see how 'intelligent' the removeItems is for equipped weapons. Fingers crossed it does leave equipped items in hand if poss.
With FNV I had to avoid all equipped/hotkeyed/worn stuff as it was pretty random.
Tried 'Player.RemoveItem(BagOfHoldingSortStavesFLST, Player.GetItemCount(BagOfHoldingSortStavesFLST) - 2, True, Self)' with two staves equipped and all were removed
including the two that were equipped. ={
Inner loop: Might be worth a shot, but I think I'll make more specific, smaller FLSTs to add to BagOfHoldingSortWeaponsAllFLST and simultaneously add more sorting options, then all should happen faster. Thankfully, the player can go about their business until the sorting is done, but with every weapon in the game, it took about 3-5 minutes (made coffee, came back and it was still going at it) to finish and right/left hand weapons were still equipped. The bag blinking is inconsequential as it takes just as long if doing it without the inventory/container UI up.
Justin, not sure if this helps, but couldn't you isolate the IsEquipped (weapon) form, then do a small loop just for that item and remove item either at one shot -1 (or -2) to see if it works, or use a
if !IsEquipped, then if count > than 1 or 2 (dual wield), remove by 1 until left with just 1 or 2?
not sure if I just made sense.. Sorry.
From some stuff I've done, I think that http://www.creationkit.com/DropObject_-_ObjectReference would first look through the inventory for unequipped items, while http://www.creationkit.com/RemoveItem_-_ObjectReference seems to have a preference for equipped items.
I'm gonna keep trying, but so far even if subtracting the number of equipped members from aiCount, RemoveItem() took them all.
Carp: "If you pass in a form list, it will remove aiCount of each item in the form list from the container. If there isn't aiCount of a particular item in the container, it will remove all of them" (Wiki).