Hello all, thank you very much for your answers!
Usually I hate asking questions that are answered by RTFM but just now it seems to me I don't know enough to even locate the info in the docs. So I apologize in advance!
I can only think of a quick way to remove all vanilla items-> by putting those in form list and comparing with the container by using http://www.creationkit.com/AddInventoryEventFilter_-_ObjectReference. (you need a new form list as it won't take nested ones) But that won't work for modded items
This seems to be the approach to items not covered by their own form (crafting materials being MISC). I guess one could write a couple of lists and use only one script handling a particular list as property, thus having neatly separated code from data

The con, as you said, is that the lists will have to be adjusted for other mods. And I really don't want to put all of the alchemy ingredients into a list, manually (CK has File-Export-Ammo, but nothing for the other item types I'm interested in).
Does someone know
- of a way to extract all items of a given form type from the CK
- where the ingredients for a recipe are stored (COBJ forms? ) and can be extracted (I mean raw materials for cooked/crafted items)
- if there is a way (dreaming...) of defining a list externally by putting the strings into an config file and build a list suitable for use with AddInventoryEventFilter
While writing, I realize I cannot add items to a duplicated FLST? I thought I read that someone had done this....
(Edit: found it: you have to drag a new item into the list, did I mention I hate GUIs for repetitive actions?)
- I hope, AddForm works on a user-generated empty list?
- Where would I put the population of the list? I guess to AddForm the same thing multiple times would be bad? What's the lifetime of a modified FLST - just for script execution, for a game session or even stored into the savegame? Depending on the answer the list generation would have to be done every time the script is called, once at game start or at game start including a check if the item added is already present.
I wanted to set up a button that when activated would remove all item types (say Staves) and put them in a container.
That's the same thing I'd like to do: some containers that will fetch items of a certain kind from the inventory and, expanding that, a port of my old http://tes.nexusmods.com/downloads/file.php?id=23857 mod.
Without the ability to loop through inventory items, there isn't really any way to look into a container's inventory unless you already know the specific items that you're looking for. You could try coupling a couple of calls to http://www.creationkit.com/RemoveAllItems_-_ObjectReference with an http://www.creationkit.com/OnItemAdded_-_ObjectReference event to detect the items currently in a container and, perhaps, build a FormList with this information. Cipscis
So for inventory looping I'll have to wait for SKSE? And something like (OBSE)
let Items := player.GetItems ItemID
is out of the question for now?
Regarding RemoveAllItems: at least using this to put all items from the player into another container, filter them using OnItemAdded and put those not to store back into the player's inventory seems quite dangerous because items equipped will also be affected and it would be quite complicated to handle putting them back on.
Perhaps a combination of AddInventoryEnventFilter, OnItemRemoved (from player) and RemoveAllItems will be possible?
There is a way to check the types. I noticed it while looking at the ingame Bookshelf code. Cast the object to the type you are checking. If it casts to None then it's not the right type of object.
That's interesting. Though it will only work when there is a suitable type to check against. So definitely not for ores/ingots as they are MISC items. But arrows could be handled using AMMO and there is a definite appeal to using INGR instaed of building an alchemy ingredient list manually...
Returning to the apologizing part: I'd be grateful to everyone who could share some code snippets regarding the usage of the Papyrus methods mentioned above. That alone would greatly speed my progress (yesterday I needed 2 hours just to attach a debug.notification script to a container activation...)
Spoiler Scriptname EK_ArrowBarrelScript extends ObjectReferenceEvent OnActivate(ObjectReference akActionRef) if (akActionRef == Game.GetPlayer()) Debug.Notification("EK_ArrowBarrelScript saw player") Game.GetPlayer().RemoveAllItems(akTransferTo = None, \ abKeepOwnership = true, \ abRemoveQuestItems = false) endifEndEvent And, on a last note, do you have a pointer to something telling me how to implement a simple yes/no choicebox, similar to the one I used in this Fallout Code?
Spoiler Begin OnActivate if ( IsActionRef Player == 1 ) ShowMessage EKAmmoLockerMsg1 set sStage to 1 else set sStage to 1 Activate endifendBegin GameMode if sStage == 0 return endif set Button to GetButtonPressed if ( Button == 0 ) ; do something special endif set sStage to 0 Activateend
Edit: I'm struggeling a bit with the basic concepts. Say I want to add an item defined in the CK to a list (or just do something with it in the Papyrus script (I tried Game.GetPlayer().AddItem)), is it correct that
Extending this I could create a FLST in the CK (dragging...) and declare it as a property in the script?