Morrowind Mod:XContentList

The UESPWiki – Your source for The Elder Scrolls since 1995
Jump to: navigation, search

A function added by MWSE.

xContentList is an alternative to both the xInventory and xNextStack functions, which returns seven values based on the inventory of the current container, NPC, or creature rather than three. If the input parameter value is 0, the first item in the current container, NPC, or creatures is returned (like xInventory). The seventh (last) value returned can also be used as the input parameter to access the next item in the inventory (like xNextStack). Whenever the items in the container change, the next reference may be invalid and you should start again with a value of 0 for the input parameter.

The first return value is the objectid of one of the items in inventory. The second is the number of that particular item found in the inventory. The third is the type of that item using the codes listed for the xRefType function. The next three parameters are the value, weight, and printable name of the item unless the object is of the Levelled Item type.
For LEVI objects, the value and weight will be listed as 0 and the name field will contain a randomly selected object id for one random item selected from the levelled list. The normal levelled list rules aren't followed and lower level items are always more likely than higher level items. Getting random id code is bugged, it sometimes returns the same id several times in a row from a leveled list of any size.

In v0.9.4a, the value and weight for ammo and repair items and name for ammo and lockpicks that are returned are invalid. This is fixed in the MWSE update released by Merzasphor.

Syntax[edit]

objectid (string) count (long) type (long) value (long) weight (float) name (string) next (reference): ref->xContentList next (reference)

Example[edit]

long target                ;target reference
long invid              ;id of item in target's inventory
long invcount           ;count of item in inventory
long invtype            ;item type
long invvalue           ;value
float invweight         ;item weight
long invname            ;name of item
long invref             ;ref to get next item in stack

ifx ( invref )          ;working through the stack
        setx invid invcount invtype invvalue invweight invname invref to target->xContentList invref
else                     ;at the beginning of inventory stack
        setx invid invcount invtype invvalue invweight invname invref to target->xContentList 0
endif
if ( invref == 0 )      ;at the end of the list
        return
endif

See Also[edit]

xInventory
xNextStack
xAddItem
xRemoveItem
xHasItemEquipped
xEquip
xDrop
xAddSpell
xRemoveSpell