Background for Skyrim SE
Member of the ObjectReference script
FormfunctionGetNthForm(intindex)Native

Description

Wiki Description

Returns the Nth form within a container relative to the total number acquired with ObjectReference.GetNumItems(). (This function requires SKSE)


Caveats

CK Wiki - Notes

  • The Index of a form in the container is relative to the number of form types regardless of the count of any particular form. If a container has only ten gold and a torch, ObjectReference.GetNumItems() will return '2' and not '11', so passing '3' as the Index argument of GetNthForm in such a case would return NONE.

Parameters

intindex


Examples

Form kForm = MQ101AlduinREF.GetNthForm(0)
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

Auto-Generated Example

int myInt__index

Form returnedValue = myObjectReference__toCallFunctionOn.GetNthForm(myInt__index)

Related Pages


Additional References

View this function’s page on the Skyrim Creation Kit Wiki

Some data provided by the Skyrim Creation Kit Wiki. Licensed under the Creative Commons Attribution-ShareAlike license.