Morrowind Mod:XInventory
A function added by MWSE.
xInventory returns three values based on the inventory of the current container, NPC, or creature. The first is the objectid of one of the items in the inventory. The second is the number of that particular item found in the inventory. The third is a reference that can be passed to the xNextStack function to find the rest of the items in the inventory. All three results will be 0 if there are no items in the inventory (and just the third will be zero if there is only one item in the inventory). (It is not possible to get a normal reference to objects inside an inventory. The reference returned by this function is of a unique type and should only be used with xNextStack.)
Syntax[edit]
objectid (string) count (long) next (reference): ref->xInventory
Example[edit]
Place following script on a container. When container is activated file containing IDs of items in the container will be created in Data Files\MWSE folder.
long ID long count long next_ref short do if ( onactivate == 1 ) set do to 1 endif ifx ( do ) ifx ( next_ref ) setx ID count next_ref to xNextStack next_ref else setx ID count next_ref to xInventory ; get first reference endif xFileWriteText "Items_in_container.txt" "%s%n%" ID if ( next_ref == 0 ) set do to 0 ; end of list endif endif
See Also[edit]
xNextStack
xContentList
xAddItem
xRemoveItem
xHasItemEquipped
xEquip
xDrop
xAddSpell
xRemoveSpell