Difference between revisions of "User:DavidJCobb/Sandbox/TES5Edit Scripting Functions"
Jump to navigation
Jump to search
User:DavidJCobb/Sandbox/TES5Edit Scripting Functions (edit)
Revision as of 20:01, 7 May 2017
, 20:01, 7 May 2017Several additions and corrections -- thanks, /u/Galahi!
imported>DavidJCobb (→IwbContainer: how did I forget these) |
imported>DavidJCobb (Several additions and corrections -- thanks, /u/Galahi!) |
||
Line 50: | Line 50: | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|EnableSkyrimSaveFormat|| | |EnableSkyrimSaveFormat|| | ||
| | |As of xEdit 3.1.2, calling this function will corrupt saved plugins until xEdit is restarted.}} | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|GetRecordDefNames||akList: TStrings | |GetRecordDefNames||akList: TStrings | ||
Line 56: | Line 56: | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|wbFilterStrings||akListIn: TStrings;<br/> akListOut: TStrings;<br/> asFilter: String | |wbFilterStrings||akListIn: TStrings;<br/> akListOut: TStrings;<br/> asFilter: String | ||
|Modifies ''akListOut'', adding every entry in ''akListIn'' that contains ''asFilter''.}} | |Modifies ''akListOut'', adding every entry in ''akListIn'' that contains the substring ''asFilter''.}} | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|wbRemoveDuplicateStrings||akList: TStringList | |wbRemoveDuplicateStrings||akList: TStringList | ||
|Modifies ''akList'', removing duplicate entries that it contains.}} | |Modifies ''akList'', removing any duplicate entries that it contains.}} | ||
|} | |} | ||
Line 73: | Line 73: | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|BaseName|string|aeElement: IwbElement | |BaseName|string|aeElement: IwbElement | ||
| | |Identical to ''Name'' except that it handles IwbFiles differently. ''Name'' will prepend a load order index (i.e. <code>[02] PluginName.esp</code>), while ''BaseName'' will not.}} | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|BuildRef||aeElement: IwbElement | |BuildRef||aeElement: IwbElement | ||
|Builds reference information for the element. Note that this function will run even if reference information has already been built.}} | |Builds reference information for the element and all of its descendants. Note that this function will run even if reference information has already been built.}} | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|CanContainFormIDs|boolean|aeElement: IwbElement | |CanContainFormIDs|boolean|aeElement: IwbElement | ||
| | |Guaranteed to return ''True'' if the element can contain form IDs, but not guaranteed to return ''False'' if it can't. This accesses an internal property, ''CanContainFormIDs'', which the internal implementation of ''BuildRef'' uses to skip processing certain descendant elements.}} | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|CanMoveDown|boolean|aeElement: IwbElement | |CanMoveDown|boolean|aeElement: IwbElement | ||
Line 88: | Line 88: | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|Check|string|aeElement: IwbElement | |Check|string|aeElement: IwbElement | ||
| | |Returns the error message produced when the "Check for Errors" functionality is run on ''aeElement''; or else an empty string if no error is found.}} | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|ClearElementState||aeElement: IwbElement;<br/> aiState: TwbElementState | |ClearElementState||aeElement: IwbElement;<br/> aiState: TwbElementState | ||
| | |Manipulates the internal flags of an element, e.g. <code>ClearElementState(eElement, esModified);</code>. See also: ''GetElementState'', ''SetElementState''.}} | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|DefType|TwbDefType|aeElement: IwbElement | |DefType|TwbDefType|aeElement: IwbElement | ||
Line 97: | Line 97: | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|DisplayName|string|aeElement: IwbElement | |DisplayName|string|aeElement: IwbElement | ||
|Returns the display name of the element, if it has one.}} | |Returns the display name of the element, if it has one; otherwise, this behaves identically to ''Name''. See also: ''BaseName'', ''ShortName''.}} | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|ElementAssign|IwbElement|aeContainer: IwbContainer;<br/> aiIndex: integer;<br/> aeSource: IwbElement;<br/> abOnlySK: boolean | |ElementAssign|IwbElement|aeContainer: IwbContainer;<br/> aiIndex: integer;<br/> aeSource: IwbElement;<br/> abOnlySK: boolean | ||
Line 109: | Line 109: | ||
:Element to copy from. Use ''Nil'' to create a blank element of the appropriate type. | :Element to copy from. Use ''Nil'' to create a blank element of the appropriate type. | ||
;abOnlySK | ;abOnlySK | ||
:Unknown. False appears to work. | :Unknown; believed to be a "shallow copy only" bool. False appears to work. | ||
Sample: there is a script to copy VMAD subrecords "Skyrim - Copy VMAD subrecord.pas"}} | Sample: there is a script to copy VMAD subrecords "Skyrim - Copy VMAD subrecord.pas"}} | ||
Line 126: | Line 126: | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|FullPath|string|aeElement: IwbElement | |FullPath|string|aeElement: IwbElement | ||
|Returns the full path to the element, going all the way down to its containing file. | |Returns the full path to the element, going all the way down to its containing file. See also: ''Path'', ''PathName''.}} | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|GetContainer|IwbContainer|aeElement: IwbElement | |GetContainer|IwbContainer|aeElement: IwbElement | ||
Line 138: | Line 138: | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|GetElementState|TwbElementState|aeElement: IwbElement;<br/> aiState: TwbElementState | |GetElementState|TwbElementState|aeElement: IwbElement;<br/> aiState: TwbElementState | ||
| | |Checks the internal flags of an element. See also: ''ClearElementState'', ''SetElementState''.}} | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|GetFile|IwbFile|aeElement: IwbElement | |GetFile|IwbFile|aeElement: IwbElement | ||
Line 165: | Line 165: | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|Name|string|aeElement: IwbElement | |Name|string|aeElement: IwbElement | ||
|Returns the name of the element, if it has one.}} | |Returns the name of the element, if it has one. If ''aeElement'' is an IwbFile or certain kinds of IwbMainRecords, ''Name'' will return a "pretty" name, while ''BaseName'' or ''ShortName'' will return a more basic string. See also: ''DisplayName''.}} | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|Path|string|aeElement: IwbElement | |Path|string|aeElement: IwbElement | ||
|Returns the path | |Returns the ''path component'' of ''aeElement'' -- that is, ''one single piece'' of the path that ''FullPath'' would return. You could use this when manually constructing a path to supply to ''ElementByPath''. See also (and don't confuse with): ''FullPath'', ''PathName''.}} | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|PathName|string|aeElement: IwbElement | |PathName|string|aeElement: IwbElement | ||
| | |Similar to ''FullPath'' except that names in the path are prefixed with brackets, to uniquely identify each element's unique position among its siblings (see ''IndexOf''). | ||
Example: <code>\[02] neromancer.esp\[7] Worldspace\[1] World Children\[1] Children of 00000D74\[0] Persistent\[2] [REFR:00100452]</code>}} | |||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|Remove||aeElement: IwbElement | |Remove||aeElement: IwbElement | ||
|Removes the element from its file.}} | |Removes the element from its file.}} | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|ReportRequiredMasters||aeElement: IwbElement;<br/> | |ReportRequiredMasters||aeElement: IwbElement;<br/> akListOut: TStrings;<br/> akUnknown1: boolean;<br/> akUnknown2: boolean | ||
| | |Checks which master files ''aeElement'' depends on, and adds their filenames to ''akListOut''. The boolean arguments' purposes are unknown, but the "Report masters.pas" script passes ''False'' for both.}} | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|SetEditValue|string|aeElement: IwbElement;<br/> asValue: string | |SetEditValue|string|aeElement: IwbElement;<br/> asValue: string | ||
Line 183: | Line 185: | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|SetElementState|TwbElementState|aeElement: IwbElement;<br/> aiState: TwbElementState | |SetElementState|TwbElementState|aeElement: IwbElement;<br/> aiState: TwbElementState | ||
| | |Manipulates the internal flags of an element. Returns the value prior to modification. See also: ''ClearElementState'', ''GetElementState''.}} | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|SetNativeValue|string|aeElement: IwbElement;<br/> avValue: variant | |SetNativeValue|string|aeElement: IwbElement;<br/> avValue: variant | ||
Line 189: | Line 191: | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|SetToDefault||aeElement: IwbElement | |SetToDefault||aeElement: IwbElement | ||
|Unknown.}} | |Unknown. Introduced in xEdit 3.1.3.}} | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|ShortName|string|aeElement: IwbElement | |ShortName|string|aeElement: IwbElement | ||
| | |Generally the same as ''Name'' unless ''aeElement'' is a reference, cell, or similar record. ''Name'' will return detailed information for those records, while ''ShortName'' will return the signature and form ID in the format <code>[XXXX:01234567]</code>.}} | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|SortKey|string|aeElement: IwbElement | |SortKey|string|aeElement: IwbElement | ||
|Returns a string unique to the element entered. This can be used for sorting elements or for comparing them; for example, you could compare the SortKey for two elements in records which override each other to see if they are different from each other.}} | |Returns a string unique to the element entered. This can be used for sorting elements or for comparing them; for example, you could compare the SortKey for two elements in records which override each other to see if they are different from each other.}} | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|wbCopyElementToFile|IwbElement|aeElement: IwbElement;<br/> aeFile: IwbFile;<br/> | |wbCopyElementToFile|IwbElement|aeElement: IwbElement;<br/> aeFile: IwbFile;<br/> abAsNew: boolean;<br/> abDeepCopy: boolean | ||
| | |Copies an IwbMainRecord, IwbGroupRecord, or IwbContainer to the specified file. The ''abAsNew'' boolean controls whether or not you're copying the record as an override record. Returns the copied element.}} | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|wbCopyElementToFileWithPrefix|IwbElement|aeElement: IwbElement;<br/> aeFile: IwbFile;<br/> | |wbCopyElementToFileWithPrefix|IwbElement|aeElement: IwbElement;<br/> aeFile: IwbFile;<br/> abAsNew: boolean;<br/> abDeepCopy: boolean;<br/> akUnknown;<br/> akUnknown;<br/> akUnknown | ||
|Details unknown. Returns the copied element.}} | |Details unknown. Returns the copied element.}} | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|wbCopyElementToRecord|IwbElement|aeElement: IwbElement;<br/> aeRecord: IwbMainRecord;<br/> | |wbCopyElementToRecord|IwbElement|aeElement: IwbElement;<br/> aeRecord: IwbMainRecord;<br/> abAsNew: boolean;<br/> abDeepCopy: boolean | ||
| | |Copies an element to a record, e.g. the "Conditions" element on a [[Constructible Object|COBJ]] record or a faction from an [[ActorBase|NPC_]] record. Returns the copied element.}} | ||
|} | |} | ||
Line 222: | Line 224: | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|AdditionalElementCount|integer|aeContainer: IwbContainer | |AdditionalElementCount|integer|aeContainer: IwbContainer | ||
|Unknown.}} | |Unknown. This getter accesses an internal function used internally for imposing some order on the sub-elements; it checks whether this element "counts," and if so, how many times. Seems to return 1 or 2 for (main?) records, and 0 for record fields (sub-records).}} | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|ContainerStates|byte|aeContainer: IwbContainer | |ContainerStates|byte|aeContainer: IwbContainer | ||
| | |Returns the internal container flags for ''aeContainer'' (e.g. whether it's initialized, or whether it has had references built) as a bitmask. Refer to "Worldspace browser.pas" for a usage example.}} | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|ElementByIndex|IwbElement|aeContainer: IwbContainer;<br/> aiIndex: integer | |ElementByIndex|IwbElement|aeContainer: IwbContainer;<br/> aiIndex: integer | ||
Line 258: | Line 260: | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|IsSorted|boolean|aeContainer: IwbSortableContainer | |IsSorted|boolean|aeContainer: IwbSortableContainer | ||
| | |Checks whether xEdit always keeps ''aeContainer'' sorted. If so, this function will return ''True'', and calling ''CanMoveUp'' and ''CanMoveDown'' on child elements will always return ''False''.}} | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|LastElement|IwbElement|aeContainer: IwbContainer | |LastElement|IwbElement|aeContainer: IwbContainer | ||
Line 291: | Line 293: | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|BaseRecordID|cardinal|aeRecord: IwbMainRecord | |BaseRecordID|cardinal|aeRecord: IwbMainRecord | ||
|}} | |Appears to return the load-order-relative form ID of ''aeRecord''.}} | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|ChangeFormSignature||aeRecord: IwbMainRecord;<br/> asNewSignature: string | |ChangeFormSignature||aeRecord: IwbMainRecord;<br/> asNewSignature: string | ||
Line 312: | Line 314: | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|GetFormVCS1|cardinal|aeRecord: IwbMainRecord | |GetFormVCS1|cardinal|aeRecord: IwbMainRecord | ||
| | |Returns the value of the Version Control Info 1 field. See also: ''SetFormVCS1''.}} | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|GetFormVCS2|cardinal|aeRecord: IwbMainRecord | |GetFormVCS2|cardinal <!-- even though the field itself is a word -->|aeRecord: IwbMainRecord | ||
| | |Returns the value of the Version Control Info 2 field. See also: ''SetFormVCS2''.}} | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|GetFormVersion|cardinal|aeRecord: IwbMainRecord | |GetFormVersion|cardinal|aeRecord: IwbMainRecord | ||
Line 399: | Line 401: | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|SetFormVCS1||aeRecord: IwbMainRecord;<br/> aiValue: cardinal | |SetFormVCS1||aeRecord: IwbMainRecord;<br/> aiValue: cardinal | ||
| | |Modifies the Version Control Info 1 field. See also: ''GetFormVCS1''.}} | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|SetFormVCS2||aeRecord: IwbMainRecord;<br/> aiValue: cardinal | |SetFormVCS2||aeRecord: IwbMainRecord;<br/> aiValue: cardinal <!-- even though the field itself is a word --> | ||
| | |Modifies the Version Control Info 2 field. See also: ''GetFormVCS2''.}} | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|Signature|string|aeRecord: IwbMainRecord | |Signature|string|aeRecord: IwbMainRecord | ||
Line 408: | Line 410: | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|UpdateRefs||aeRecord: IwbMainRecord | |UpdateRefs||aeRecord: IwbMainRecord | ||
| | |Appears to be the same as ''BuildRef'', except that it aborts if references are already in the middle of being built.}} | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|WinningOverride|IwbMainRecord|aeRecord: IwbMainRecord | |WinningOverride|IwbMainRecord|aeRecord: IwbMainRecord | ||
Line 426: | Line 428: | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|FindChildGroup|IwbGroupRecord|aeGroup: IwbGroupRecord;<br/>aiType: integer;<br/> aeMainRecord: IwbMainRecord;<br/> | |FindChildGroup|IwbGroupRecord|aeGroup: IwbGroupRecord;<br/>aiType: integer;<br/> aeMainRecord: IwbMainRecord;<br/> | ||
|Unknown.}} | |Unknown. The ''aiType'' value should match the group-type values used in [http://en.uesp.net/wiki/Tes5Mod:Mod_File_Format#Groups the file format]. The "Worldspace browser.pas" script uses <code>FindChildGroup(ChildGroup(cell), 9, cell);</code> to get the "Temporary" group within a CELL.}} | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|GroupLabel|cardinal|aeGroup: IwbGroupRecord | |GroupLabel|cardinal|aeGroup: IwbGroupRecord | ||
| | |Returns the raw group label, as specified in [http://en.uesp.net/wiki/Tes5Mod:Mod_File_Format#Groups the file format].}} | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|GroupType|integer|aeGroup: IwbGroupRecord | |GroupType|integer|aeGroup: IwbGroupRecord | ||
| | |Returns the raw group type, as specified in [http://en.uesp.net/wiki/Tes5Mod:Mod_File_Format#Groups the file format].}} | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|MainRecordByEditorID|IwbMainRecord|aeGroup: IwbGroupRecord;<br/> asEditorID: string | |MainRecordByEditorID|IwbMainRecord|aeGroup: IwbGroupRecord;<br/> asEditorID: string | ||
Line 450: | Line 452: | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|CleanMasters||aeFile: IwbFile | |CleanMasters||aeFile: IwbFile | ||
|}} | |Appears to find unnecessary files in ''aeFile''<nowiki/>'s master list and remove them, updating all form indices accordingly. Don't confuse this within "cleaning master files" as in "removing ITMs and UDRs from official DLCs." This function is used in "Skyrim - Book Covers Patch.pas".}} | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|FileFormIDtoLoadOrderFormID|cardinal|aeFile: IwbFile; aiFormID: cardinal | |FileFormIDtoLoadOrderFormID|cardinal|aeFile: IwbFile; aiFormID: cardinal | ||
Line 456: | Line 458: | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|FileWriteToStream||aeFile: IwbFile;<br/> akOutStream: TStream | |FileWriteToStream||aeFile: IwbFile;<br/> akOutStream: TStream | ||
|}} | |Writes the contents of ''aeFile'' to ''akOutStream''. Used in "SaveAs.pas" to allow a user to save a loaded file under a new name; that script creates a TFileStream object and uses this function to write to it.}} | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|GetFileName|string|aeFile: IwbFile | |GetFileName|string|aeFile: IwbFile | ||
Line 468: | Line 470: | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|GetNewFormID|cardinal|aeFile: IwbFile | |GetNewFormID|cardinal|aeFile: IwbFile | ||
|}} | |Returns a new form ID, the same way that <code>Add(..., ..., True)</code> does.}} | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|GroupBySignature|IwbGroupRecord|aeFile: IwbFile;<br/> asSignature: string | |GroupBySignature|IwbGroupRecord|aeFile: IwbFile;<br/> asSignature: string | ||
Line 508: | Line 510: | ||
==== IwbResource ==== | ==== IwbResource ==== | ||
These functions are used in "Assets browser.pas", "Assets manager.pas", and "Skyrim - List used scripts.pas". | |||
{| class="wikitable" style="background-color: #AAAAAA; cellpadding: 0" | {| class="wikitable" style="background-color: #AAAAAA; cellpadding: 0" | ||
|- align="left" | |- align="left" | ||
Line 516: | Line 520: | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|ResourceContainerList||akContainers: TwbFastStringList | |ResourceContainerList||akContainers: TwbFastStringList | ||
|Fills ''akContainers'' with the full filenames (directory + name) of all loaded BSA and BA2 files. ''akContainers'' can be a TwbFastStringList or a TStringList.}} | |Fills ''akContainers'' with the full filenames (directory + name) of all loaded BSA and BA2 files, as well as the name of the Data directory. ''akContainers'' can be a TwbFastStringList or a TStringList.}} | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|ResourceCopy|| | |ResourceCopy||asContainerName: string;<br/> asFilename: string;<br/> asPathOut: string | ||
|}} | |Retrieves the resource named ''asFilename'' from the resource container named ''asContainerName'' (see ''ResourceContainerList''), and saves that resource to the specified file path ''asPathOut''. The "Assets browser.pas" script uses this to let users extract a resource from a BSA/BA2.}} | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|ResourceCount|cardinal| | |ResourceCount|cardinal|asFilename: string;<br/> akContainers: TStrings | ||
|}} | |Fills ''akContainers'' with a list of the loaded containers (BSA, BA2, Data directory) that a file named ''asFilename'' appears in. The "Assets browser.pas" script uses this to allow users to decide which version of a file to view, when the file is overridden at least once within their load order.}} | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|ResourceExists|boolean| | |ResourceExists|boolean|asFilename: string | ||
|}} | |Checks whether any loaded container has a file with the specified name.}} | ||
{{TES5Edit function row|even | {{TES5Edit function row|even | ||
|ResourceList|| | |ResourceList||asContainerName: string;<br/> akContainers: TStrings | ||
|}} | |Accesses the container with the full filename ''asContainerName'' (see ''ResourceContainerList''), and adds a list of all contained filenames to ''akContainers''. Note that added entries are unsorted, and there may be duplicates among them.}} | ||
{{TES5Edit function row|odd | {{TES5Edit function row|odd | ||
|ResourceOpenData|TBytesStream|asContainerName: string;<br/> asFilename: string | |ResourceOpenData|TBytesStream|asContainerName: string;<br/> asFilename: string |