Difference between revisions of "GetFormFromFile - Game"

From the Fallout4 CreationKit Wiki
Jump to navigation Jump to search
imported>Docclox
m (→‎Examples: the "cast" was missing in the example, which would give a compiler error.)
imported>Qazaaq
(added see also)
 
Line 1: Line 1:
[[Category:Scripting]]
[[Category:Papyrus]]
[[Category:Non-Delayed Native Functions]]
'''Member of:''' [[Game Script]]
'''Member of:''' [[Game Script]]


Line 35: Line 32:
*[[GetForm - Game]]
*[[GetForm - Game]]
*[[GetFormID - Form]]
*[[GetFormID - Form]]
*[[IsPluginInstalled - Game]]
[[Category:Scripting]]
[[Category:Papyrus]]
[[Category:Non-Delayed Native Functions]]

Latest revision as of 08:20, 26 May 2018

Member of: Game Script

Obtains the form specified by its form ID number which originated in the specified file. The ID for a form changes based on the load order of the file it loaded from. So a form which shows up as 0101ABCD in the editor may show up as 0401ABCD in game depending on how many other files load before it. This function lets you blindly grab a form based on the lower bytes of its ID and the expected file which created the form.

Syntax[edit | edit source]

Form Function GetFormFromFile(int aiFormID, string asFilename) native global

Parameters[edit | edit source]

  • aiFormID: The form ID number of the form we want. (FormID proceeded by 0x) For example Form ID "0001ABCD" is given as: 0x0001ABCD
  • asFilename: The name of the file we expect the form to have originated in.

Return Value[edit | edit source]

The requested Form, or None if the form ID is not valid or the file does not exist or is not loaded.

Examples[edit | edit source]

Assume a mod or DLC called "KillerBees.esp" was released which made the bee critters agressive and immortal, only killable by weapons in the form list BeeKillerWeapList (0100ABCD). Another mod or DLC wants to add a BeeSlayer sword which they want to be able to kill the killer bees if you have that mod.

; Obtain form 0000ABCD we expect to be added by the KillerBees plugin
; Note the top most byte in the given ID is unused so 0000ABCD works as well as 0400ABCD
FormList beekillerlist = Game.GetFormFromFile(0x0000ABCD, "KillerBees.esp") as FormList
; If "KillerBees.esp" is not loaded the form will be NONE. Otherwise, add our weapon to the list.
if ( beekillerlist )
  beekillerlist.AddForm( WeapBeeSlayer )
endif

See Also[edit | edit source]