ListGetNthForm
From GECK
A function added by the Fallout Script Extender.
Description
Returns the nth form in the form list
Syntax
(nthForm:reference/BaseForm) ListGetNthForm formlist:baseform index:int
Example
let rForm := ListGetNthForm ExampleFormList 0 ;Will return the first element in the list.
Looping With ListGetCount
To cycle through each form in a FormList using this function and ListGetCount, here's an example:
let iSize := ListGetCount ExampleFormList while ( (iSize -= 1) >= 0) let rForm := ListGetNthForm ExampleFormList iSize ;do anything with this form. loop
Note that a backwards While loop was chosen here, since unlike with a forwards loop, forms can be safely removed from the FormList without causing the loop to fail. Besides that, forwards loops are also perfectly fine to use.
See Also
- ListGetCount
- ListClear
- To find an element: ListGetFormIndex, IsInList, IsRefInList, IsWeaponInList
- To remove an element: ListRemoveForm, ListRemoveNthForm
- To replace an element: ListReplaceForm, ListReplaceNthForm
- To add an element: ListAddForm, ListAddReference