AddForm - FormList

Revision as of 15:24, 8 March 2022 by DavidJCobb (talk | contribs) (more RE; figured out list ordering for good)

Member of: FormList Script

Adds the given form to the form list.

Syntax

Function AddForm(Form apForm) native

Parameters

  • apForm: Form to add to the list, if apForm == None this function seems to have no effect

Return Value

None

Examples

; Adds the diamond to the gem list
GemList.AddForm(Diamond)

Notes

Order of items in the list

FormLists are divided into three sections. First are all of the forms that are initially present in the FormList per its definition in the Creation Kit. Next are any forms that were not created during play (form ID does not start with 0xFF) and were added to the FormList by scripts. Last are forms that were created during play (form ID starts with 0xFF) and were added to the FormList by scripts. This means that FormLists will not necessarily store forms in the order they were added to the list.

Consider a FormList that has forms A, B, C, and D added to it in the Creation Kit.

If a script adds forms E, F, and G to the list (assuming those forms weren't created during play), then the list will contain: A B C D E F G. Now suppose the user saves the game, updates a mod, and then reloads the game. Suppose that that mod update, in the Creation Kit, adds form H to the end of the FormList. In-game, after the user loads their save file, the list will contain: A B C D H E F G.

Now, consider a FormList that has forms T, U, and V added to it in the Creation Kit.

Suppose a script adds forms W, X, Y, and Z to the FormList; however, forms W and X are forms that were created during play (e.g. ObjectReferences spawned via PlaceAtMe), while forms Y and Z are forms defined in the user's load order. The FormList will now contain: T U V Y Z W X.

Other notes

  • FormLists cannot contain duplicate entries. Using AddForm(...) with a form that is already in the list will not add a second copy to the list.
  • A created reference does not become persistent by virtue of being added to a FormList. If you try to retrieve the reference from the FormList when it is not loaded and not persistent, you will get an incorrect result or no result.

See Also