GetNumItems - ObjectReference

Revision as of 18:15, 1 March 2013 by imported>Zartar (Undo revision 39256 by Zartar (talk))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

SKSE Member of: ObjectReference Script

Minimum required SKSE Version: 1.05.01

Returns the number of items in a container. (This function requires SKSE)

SyntaxEdit

Int Function GetNumItems() Native

Return ValueEdit

Returns the number of items in a container.

ExamplesEdit

  • Check a single container.
Int iNumItems = MQ101AlduinREF.GetNumItems()
  • Set the weights of all ingredients in player's inventory to 0.1.
Actor Property PlayerREF Auto

Event SomeEvent()
	ReweighIngredientsIn(PlayerREF, 0.1)
EndEvent

Function ReweighIngredientsIn(ObjectReference akContainer, Float afWeight) Global
	Int iFormIndex = akContainer.GetNumItems()
	While iFormIndex > 0
		iFormIndex -= 1
		Form kForm = akContainer.GetNthForm(iFormIndex)
		If kForm.GetType() == 30 ; Ingredient
			kForm.SetWeight(afWeight)
		EndIf
	EndWhile
EndFunction

NotesEdit

  • The returned value indicates the number of item types in the container regardless of the count of any particular item. If a container has ten gold and a torch, GetNumItems will return '2' and not '11'.

The exception is keys, if you have two of the same key then GetNumItems will count both keys. EDIT: This could be because the keys were quest items. More testing is needed to confirm this.

See AlsoEdit