Difference between revisions of "GetFormFromFile - Game"
Jump to navigation
Jump to search
m
→Examples: Compiles. Note to self: Compile first, then save page.
imported>JustinOther m (Missed more renamed vars.) |
imported>JustinOther m (→Examples: Compiles. Note to self: Compile first, then save page.) |
||
Line 32: | Line 32: | ||
<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 '000000' instances must 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 '000000' instances must be changed to match a known existing FormID in each plugin. | ||
<source lang="papyrus"> | <source lang="papyrus">Function CheckForDLC(Int aiIndex = 0, String asDLCName = "") | ||
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 aiIndex == 0 ; Dawnguard.ESM | ||
If bDLCArray[aiIndex] != Game.GetFormFromFile(0x00000000 sDLCArray[aiIndex]) | If bDLCArray[aiIndex] != Game.GetFormFromFile(0x00000000, sDLCArray[aiIndex]) | ||
bDLCArray[aiIndex] = ! | bDLCArray[aiIndex] = !bDLCArray[aiIndex] | ||
If bDLCArray[aiIndex] | If bDLCArray[aiIndex] | ||
Debug.Trace("Dawnguard.ESM is loaded") | Debug.Trace("Dawnguard.ESM is loaded") | ||
Line 50: | Line 47: | ||
ElseIf aiIndex == 1 ; Hearthfire.ESM | ElseIf aiIndex == 1 ; Hearthfire.ESM | ||
If bDLCArray[aiIndex] != Game.GetFormFromFile(0x00000000, sDLCArray[aiIndex]) | If bDLCArray[aiIndex] != Game.GetFormFromFile(0x00000000, sDLCArray[aiIndex]) | ||
bDLCArray[aiIndex] = ! | bDLCArray[aiIndex] = !bDLCArray[aiIndex] | ||
If bDLCArray[aiIndex] | If bDLCArray[aiIndex] | ||
Debug.Trace("Hearthfire.ESM is loaded") | Debug.Trace("Hearthfire.ESM is loaded") | ||
Line 59: | Line 56: | ||
ElseIf aiIndex == 2 ; KillerBees.esp | ElseIf aiIndex == 2 ; KillerBees.esp | ||
If bDLCArray[aiIndex] != Game.GetFormFromFile(0x0000ABCD, sDLCArray[aiIndex]) | If bDLCArray[aiIndex] != Game.GetFormFromFile(0x0000ABCD, sDLCArray[aiIndex]) | ||
bDLCArray[aiIndex] = ! | bDLCArray[aiIndex] = !bDLCArray[aiIndex] | ||
If bDLCArray[aiIndex] | If bDLCArray[aiIndex] | ||
Debug.Trace("KillerBees.esp izzz loaded") | Debug.Trace("KillerBees.esp izzz loaded") | ||
Line 73: | Line 70: | ||
EndWhile | EndWhile | ||
EndFunction</source> | EndFunction</source> | ||
== Notes == | == Notes == | ||
*If asFilename is not loaded, it will be reported in one's log. | *If asFilename is not loaded, it will be reported in one's log. |