[DEV SERVER] Loading description...
Caveats
CK Wiki - Notes
- If asFilename is not loaded, it will be reported in one's log.
- Don't forget to cast if setting a property to any given form type with GetFormFromFile.
- Almost invariably, a plugin will have a form with 0x00000800 or 0x00000D62 as its FormID. The latter for a plugin that is masterless when its first form is created and the former when another plugin is loaded at that time. Checking for both FormIDs in most plugins will suffice to merely determine if asFileName is loaded, but there's always the possibility the first form added gets deleted in which case you'd get a false negative. Whenever possible, use a verified FormID that is likely to remain in asFileName.
Parameters
intaiFormID
CK Wiki Description
The form ID number of the form we want. (FormID proceeded by 0x) For example Form ID "0001ABCD" is given as:0x0001ABCD
stringasFilename
CK Wiki Description
The name of the file we expect the form to have originated in.
Examples
; 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 )
endifBool bIsBagOfHoldingLoaded = Game.GetFormFromFile(0x000012EE, "Bag of Holding.esp") ; Is Bag of Holding.esp loaded?Bool[] Property bDLCIsLoaded Auto ; Element 0 is bDawnguard, etc.
Int[] Property iKnownFormID Auto ; Element 0 is 2048 for Dawnguard's DLC1AurielsBow "Auriel's Bow" [WEAP:02000800], etc.
String[] Property sDLCName Auto ; Element 0 is Dawnguard.ESM, Element 1 is HearthFires.ESM, element 2 is Dragonborn.ESM, etc.
Function CheckForDLC()
Int iIndex = sDLCName.Length
While iIndex
iIndex -= 1
If bDLCIsLoaded[iIndex] != Game.GetFormFromFile(iKnownFormID[iIndex], sDLCName[iIndex])
bDLCIsLoaded[iIndex] = !bDLCIsLoaded[iIndex]
If bDLCIsLoaded[iIndex]
Debug.Trace(sDLCName[iIndex] + " is loaded")
If iIndex == 0 ; Dawnguard
; Make any changes needed for Dawnguard
ElseIf iIndex == 1 ; Hearthfire
; Make any changes needed for Hearthfire
ElseIf iIndex == 2 ; Dragonborn
; Make any changes needed for Dragonborn
EndIf
Else
Debug.Trace(sDLCName[iIndex] + " was loaded, but is no longer")
If iIndex == 0 ; Dawnguard
; Revert any changes previously made for Dawnguard
ElseIf iIndex == 1 ; Hearthfire
; Revert any changes previously made for Hearthfire
ElseIf iIndex == 2 ; Dragonborn
; Revert any changes previously made for Dragonborn
EndIf
EndIf
EndIf
EndWhile
EndFunctionAuto-Generated Example
int myInt__aiFormID
string myString__asFilename
Form returnedValue = Game.GetFormFromFile(myInt__aiFormID, myString__asFilename)