Difference between revisions of "GetFormFromFile - Game"

Jump to navigation Jump to search
80 bytes removed ,  23:37, 21 August 2012
→‎Examples: CheckForDLC edited to also look for 0x00000D62 per suggestion in talk page/condensed
imported>JustinOther
m (→‎Examples: 0x00000800 FormID will probably exist as a new plugin's NOID dictates)
imported>JustinOther
(→‎Examples: CheckForDLC edited to also look for 0x00000D62 per suggestion in talk page/condensed)
Line 31: Line 31:
*To merely detect if a plugin is loaded.
*To merely detect if a plugin is loaded.
<source lang="papyrus">Bool bIsBagOfHoldingLoaded = Game.GetFormFromFile(0x000012EE, "Bag of Holding.esp") ; Is Bag of Holding.esp loaded?</source>
<source lang="papyrus">Bool bIsBagOfHoldingLoaded = Game.GetFormFromFile(0x000012EE, "Bag of Holding.esp") ; Is Bag of Holding.esp loaded?</source>
*Say you want to detect if DLCs are loaded and need to do/undo something in the event a DLC is added or removed from the user's load list: Create a boolean and string array, each with one element per DLC to check. When setting up the properties, leave the boolean elements with their default 'False' values and set each string element with the exact name of the plugin to check for such that their indices correspond. For this to work, the '0x00000800' instances ''might'' need to be changed to match a known existing FormID in each plugin.
*Say you want to detect if DLCs are loaded and need to do/undo something in the event a DLC is added or removed from the user's load list: Create a boolean and string array, each with one element per DLC to check. When setting up the properties, leave the boolean elements with their default 'False' values and set each string element with the exact name of the plugin to check for such that their indices correspond. For this to work, the '0x00000800' and '0x00000D62' instances ''might'' need to be changed to match a known existing FormID in each plugin. If another plugin is loaded when a plugin's first form is created, it will be an 0x00000D62. There is no guarantee a plugin will have either, however.
<source lang="papyrus">Bool[] Property bDLCArray Auto
<source lang="papyrus">Function CheckForDLC(Int aiIndex = 0, String asDLCName = "")
String[] Property sDLCArray Auto
 
Function CheckForDLC(Int aiIndex = 0, String asDLCName = "")
aiIndex = bDLCArray.Length
aiIndex = bDLCArray.Length
While aiIndex > 0
While aiIndex > 0
aiIndex -= 1
aiIndex -= 1
If aiIndex == 0 ; Dawnguard.ESM
If bDLCArray[aiIndex] != (Game.GetFormFromFile(0x00000800, sDLCArray[aiIndex]) || Game.GetFormFromFile(0x00000D62, sDLCArray[aiIndex]))
If bDLCArray[aiIndex] != Game.GetFormFromFile(0x00000800, sDLCArray[aiIndex])
bDLCArray[aiIndex] = !bDLCArray[aiIndex]
bDLCArray[aiIndex] = !bDLCArray[aiIndex]
If bDLCArray[aiIndex]
If bDLCArray[aiIndex]
Debug.Trace(sDLCArray[aiIndex] + " is loaded")
Debug.Trace("Dawnguard.ESM is loaded")
If aiIndex == 0 ; Dawnguard
Else
; Make any changes needed for Dawnguard
Debug.Trace("Dawnguard.ESM was loaded, but is no longer")
ElseIf aiIndex == 1 ; Hearthfire
; Make any changes needed for Hearthfire
ElseIf aiIndex == 2 ; KillerBees
; Make any changes needed for KillerBees
EndIf
EndIf
EndIf
Else
ElseIf aiIndex == 1 ; Hearthfire.ESM
Debug.Trace(sDLCArray[aiIndex] + " was loaded, but is no longer")
If bDLCArray[aiIndex] != Game.GetFormFromFile(0x00000800, sDLCArray[aiIndex])
If aiIndex == 0 ; Dawnguard
bDLCArray[aiIndex] = !bDLCArray[aiIndex]
; Revert any changes previously made for Dawnguard
If bDLCArray[aiIndex]
ElseIf aiIndex == 1 ; Hearthfire
Debug.Trace("Hearthfire.ESM is loaded")
; Revert any changes previously made for Hearthfire
Else
ElseIf aiIndex == 2 ; KillerBees
Debug.Trace("Hearthfire.ESM was loaded, but is no longer")
; Revert any changes previously made for KillerBees
EndIf
EndIf
ElseIf aiIndex == 2 ; KillerBees.esp
If bDLCArray[aiIndex] != Game.GetFormFromFile(0x0000ABCD, sDLCArray[aiIndex])
bDLCArray[aiIndex] = !bDLCArray[aiIndex]
If bDLCArray[aiIndex]
Debug.Trace("KillerBees.esp izzz loaded")
Else
Debug.Trace("KillerBees wazzz loaded, but izzz no longer")
EndIf
EndIf
EndIf
EndIf
ElseIf aiIndex == 3 ; DLC04.ESM
; etc.
ElseIf aiIndex == 4 ; DLC05.ESM
; etc.
EndIf
EndIf
EndWhile
EndWhile
Anonymous user

Navigation menu