GetFormFromFile - Game: Difference between revisions
Jump to navigation
Jump to search
Took out guesswork via addition of FormID array
imported>JustinOther (→Examples: CheckForDLC edited to also look for 0x00000D62 per suggestion in talk page/condensed) |
imported>JustinOther (Took out guesswork via addition of FormID array) |
||
| 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 | *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 such that their indices correspond. 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">Function CheckForDLC(Int aiIndex = 0, String asDLCName = "") | <source lang="papyrus">Bool[] Property bDLCArray Auto ; Element 0 is bDawnguard, etc. | ||
Int[] Property iFormIDArray 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. | |||
Function CheckForDLC(Int aiIndex = 0, String asDLCName = "") | |||
aiIndex = bDLCArray.Length | aiIndex = bDLCArray.Length | ||
While aiIndex > 0 | While aiIndex > 0 | ||
aiIndex -= 1 | aiIndex -= 1 | ||
If bDLCArray[aiIndex] != | If bDLCArray[aiIndex] != Game.GetFormFromFile(iFormID, sDLCArray[aiIndex]) | ||
bDLCArray[aiIndex] = !bDLCArray[aiIndex] | bDLCArray[aiIndex] = !bDLCArray[aiIndex] | ||
If bDLCArray[aiIndex] | If bDLCArray[aiIndex] | ||