as I originally wanted to try but per the wiki I thought that filter 14 would not work. If this DOES works as Mr. Spaniard says it will I will update the wiki article myself.
This was asked in the OBSE thread just a week or two ago, and scruggsy said it worked fine and even tested it (he had no idea why the wiki said what it does).
Thanks for the little script you wrote anyway as you just enlightened me one very important command that is not well described (not in an obvious way) in the OBSE docs.
ForEach item <- player
The only thing that comes close to a description of this command (that I could find) is buried in text about the FOREACH command. This (<-) is a GREAT command and I wish it had been featured as the other commands more prominently, could have used this dozens of time in my past scripts and I will be using this a HECK of a lot from now on.
Just note that the "ForEach item <- player" loop does something else than the GetNumItems/GetInventoryObject loop you may have used before.
E.g. look at those to script snippets:
let i := 0 While i < player.GetNumItems let item := player.GetInventoryObject i ; item is now a base object let i += 1Loop
ForEach item <- player ; item is now a reference Loop
As indicated in the comment, the first gives you a base object while the second gives you a reference. Since the second gives you a reference, it will not necessarily give you all items of a base object at the same time. E.g. assume the player has nothing but three identical swords in his inventory, but one of them has been damaged:
The first loop will iterate only once, giving you the base sword object, and "player.GetItemCount item" will return 3.
The second loop will iterate twice, once giving you the reference to the damaged weapon and once giving you the reference to the two other weapons. "item.GetRefCount" will return "1" and "2" within those two loops. I'm not sure if "player.GetItemCount item", will work at all since item is a reference, but if it works, I am pretty sure it will return 3 in both iterations of the loop.
Anyway, the difference is quite important, and I recommend that you use the right loop for the job you need. For example, in your Archery mod where you adjust base health, damage and gold for arrows and bows, you are doing so on the base objects, so the first loop is best. On the other hand, if you want to adjust the current health of specific bows in the inventory, to ensure their health percentage stays correct after the base health adjustment, you need to use the second loop to access the reference to one specific bow in order to adjust that bow's current health.