Difference between revisions of "GetNthForm - ObjectReference"
Jump to navigation
Jump to search
imported>Cipscis m (Removing extra apostrophe) |
imported>JustinOther m (SKSE Version Template) |
||
(One intermediate revision by the same user not shown) | |||
Line 3: | Line 3: | ||
[[Category:SKSE]] | [[Category:SKSE]] | ||
'''SKSE Member of:''' [[ObjectReference Script]] | '''SKSE Member of:''' [[ObjectReference Script]] | ||
{{SKSEFunction|1.05.01}} | |||
Returns the Nth form within a container relative to the total number acquired with [[GetNumItems - ObjectReference|GetNumItems]]. (This function requires SKSE) | Returns the Nth form within a container relative to the total number acquired with [[GetNumItems - ObjectReference|GetNumItems]]. (This function requires SKSE) | ||
Line 27: | Line 29: | ||
EndEvent | EndEvent | ||
Function ReweighIngredientsIn(ObjectReference akContainer, Float | Function ReweighIngredientsIn(ObjectReference akContainer, Float afWeight) Global | ||
Int iFormIndex = akContainer.GetNumItems() | Int iFormIndex = akContainer.GetNumItems() | ||
While iFormIndex > 0 | While iFormIndex > 0 | ||
Line 33: | Line 35: | ||
Form kForm = akContainer.GetNthForm(iFormIndex) | Form kForm = akContainer.GetNthForm(iFormIndex) | ||
If kForm.GetType() == 30 ; Ingredient | If kForm.GetType() == 30 ; Ingredient | ||
kForm.SetWeight( | kForm.SetWeight(afWeight) | ||
EndIf | EndIf | ||
EndWhile | EndWhile |
Latest revision as of 22:53, 13 February 2013
SKSE Member of: ObjectReference Script
Minimum required SKSE Version: 1.05.01
Returns the Nth form within a container relative to the total number acquired with GetNumItems. (This function requires SKSE)
Syntax[edit | edit source]
Form Function GetNthForm(Int Index) Native
Return Value[edit | edit source]
Returns the Nth form in the calling container.
Notes[edit | edit source]
- 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, GetNumItems will return '2' and not '11', so passing '3' as the Index argument of GetNthForm in such a case would return NONE.
Examples[edit | edit source]
- Check a single container.
Form kForm = MQ101AlduinREF.GetNthForm(0)
- 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