Difference between revisions of "GetFormFromFile - Game"
Jump to navigation
Jump to search
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 | <source lang="papyrus">Bool[] Property bDLCIsLoaded Auto ; Element 0 is bDawnguard, etc. | ||
Int[] Property | Int[] Property iKnownFormID Auto ; Element 0 is 2048 for Dawnguard's DLC1AurielsBow "Auriel's Bow" [WEAP:02000800], etc. | ||
String[] Property | String[] Property sDLCName Auto ; Element 0 is Dawnguard.ESM, etc. | ||
Function CheckForDLC( | Function CheckForDLC() | ||
Int iIndex = sDLCName.Length | |||
While | While iIndex > 0 | ||
iIndex -= 1 | |||
If bDLCArray[ | If bDLCArray[iIndex] != Game.GetFormFromFile(iKnownFormID[iIndex], sDLCName[iIndex]) | ||
bDLCIsLoaded[iIndex] = !bDLCIsLoaded[iIndex] | |||
If | If bDLCIsLoaded[iIndex] | ||
Debug.Trace( | Debug.Trace(sDLCName[iIndex] + " is loaded") | ||
If | If iIndex == 0 ; Dawnguard | ||
; Make any changes needed for Dawnguard | ; Make any changes needed for Dawnguard | ||
ElseIf | ElseIf iIndex == 1 ; Hearthfire | ||
; Make any changes needed for Hearthfire | ; Make any changes needed for Hearthfire | ||
ElseIf | ElseIf iIndex == 2 ; KillerBees | ||
; Make any changes needed for KillerBees | ; Make any changes needed for KillerBees | ||
EndIf | EndIf | ||
Else | Else | ||
Debug.Trace( | Debug.Trace(sDLCName[iIndex] + " was loaded, but is no longer") | ||
If | If iIndex == 0 ; Dawnguard | ||
; Revert any changes previously made for Dawnguard | ; Revert any changes previously made for Dawnguard | ||
ElseIf | ElseIf iIndex == 1 ; Hearthfire | ||
; Revert any changes previously made for Hearthfire | ; Revert any changes previously made for Hearthfire | ||
ElseIf | ElseIf iIndex == 2 ; KillerBees | ||
; Revert any changes previously made for KillerBees | ; Revert any changes previously made for KillerBees | ||
EndIf | EndIf |