Difference between revisions of "GetFormFromFile - Game"

21 bytes removed ,  10:50, 28 September 2012
m
→‎Examples: Semantics/Renamed arguments
imported>JLundin
imported>JustinOther
m (→‎Examples: Semantics/Renamed arguments)
Line 33: Line 33:
<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, Int, and String array, each with one element per DLC to check such that the indices of all three correspond. Leave the boolean elements with their default 'False' values and set each string element with the exact name of the plugin to check for. For this to work, the Int[] elements must match known existing FormIDs in the corresponding plugins converted from Hex to Dec (easily done with Windows' calculator in programmer mode).
*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, Int, and String array, each with one element per DLC to check such that the indices of all three correspond. Leave the boolean elements with their default 'False' values and set each string element with the exact name of the plugin to check for. For this to work, the Int[] elements must match known existing FormIDs in the corresponding plugins converted from Hex to Dec (easily done with Windows' calculator in programmer mode).
<source lang="papyrus">Bool[] Property bDLCArray Auto ; Element 0 is bDawnguard, etc.
<source lang="papyrus">Bool[] Property bDLCIsLoaded Auto ; Element 0 is bDawnguard, etc.
Int[] Property iFormIDArray Auto ; Element 0 is 2048 for Dawnguard's DLC1AurielsBow "Auriel's Bow" [WEAP:02000800], etc.
Int[] Property iKnownFormID Auto ; Element 0 is 2048 for Dawnguard's DLC1AurielsBow "Auriel's Bow" [WEAP:02000800], etc.
String[] Property sDLCArray Auto ; Element 0 is Dawnguard.ESM, etc.
String[] Property sDLCName Auto ; Element 0 is Dawnguard.ESM, etc.


Function CheckForDLC(Int aiIndex = 0)
Function CheckForDLC()
aiIndex = bDLCArray.Length
Int iIndex = sDLCName.Length
While aiIndex > 0
While iIndex > 0
aiIndex -= 1
iIndex -= 1
If bDLCArray[aiIndex] != Game.GetFormFromFile(iFormIDArray[aiIndex], sDLCArray[aiIndex])
If bDLCArray[iIndex] != Game.GetFormFromFile(iKnownFormID[iIndex], sDLCName[iIndex])
bDLCArray[aiIndex] = !bDLCArray[aiIndex]
bDLCIsLoaded[iIndex] = !bDLCIsLoaded[iIndex]
If bDLCArray[aiIndex]
If bDLCIsLoaded[iIndex]
Debug.Trace(sDLCArray[aiIndex] + " is loaded")
Debug.Trace(sDLCName[iIndex] + " is loaded")
If aiIndex == 0 ; Dawnguard
If iIndex == 0 ; Dawnguard
; Make any changes needed for Dawnguard
; Make any changes needed for Dawnguard
ElseIf aiIndex == 1 ; Hearthfire
ElseIf iIndex == 1 ; Hearthfire
; Make any changes needed for Hearthfire
; Make any changes needed for Hearthfire
ElseIf aiIndex == 2 ; KillerBees
ElseIf iIndex == 2 ; KillerBees
; Make any changes needed for KillerBees
; Make any changes needed for KillerBees
EndIf
EndIf
Else
Else
Debug.Trace(sDLCArray[aiIndex] + " was loaded, but is no longer")
Debug.Trace(sDLCName[iIndex] + " was loaded, but is no longer")
If aiIndex == 0 ; Dawnguard
If iIndex == 0 ; Dawnguard
; Revert any changes previously made for Dawnguard
; Revert any changes previously made for Dawnguard
ElseIf aiIndex == 1 ; Hearthfire
ElseIf iIndex == 1 ; Hearthfire
; Revert any changes previously made for Hearthfire
; Revert any changes previously made for Hearthfire
ElseIf aiIndex == 2 ; KillerBees
ElseIf iIndex == 2 ; KillerBees
; Revert any changes previously made for KillerBees
; Revert any changes previously made for KillerBees
EndIf
EndIf
Anonymous user