Difference between revisions of "TES5Edit Scripting Functions"
added a whole bunch of explanations
imported>Mator |
imported>Mator (added a whole bunch of explanations) |
||
Line 12: | Line 12: | ||
=== TES5Edit Scripting Functions === | === TES5Edit Scripting Functions === | ||
The types described by this table such as IwbElement, IwbFile, etc.. are internal and not directly accessible but instead the script engine receives a generic type named <b>IInterface</b> which is common to every object type returned by TES5Edit. | The types described by this table such as IwbElement, IwbFile, etc.. are internal and not directly accessible but instead the script engine receives a generic type named <b>IInterface</b> which is common to every object type returned by TES5Edit. | ||
The reason the internal types are shown in this table is because some functions expect references to specific types even if the object reference is being | The reason the internal types are shown in this table is because some functions expect references to specific types even if the object reference is being held by the generic IInterface variable. | ||
{| class="wikitable" style="background-color: #AAAAAA; cellpadding: 0" | {| class="wikitable" style="background-color: #AAAAAA; cellpadding: 0" | ||
Line 93: | Line 93: | ||
| scope="row" | <b>FindChildGroup</b> || IwbGroupRecord || group : IwbGroupRecord , aType : integer , aMainRecord : IwbMainRecord || | | scope="row" | <b>FindChildGroup</b> || IwbGroupRecord || group : IwbGroupRecord , aType : integer , aMainRecord : IwbMainRecord || | ||
|- align="left" style="background-color: #F8F8F8" | |- align="left" style="background-color: #F8F8F8" | ||
| scope="row" | <b>FixedFormID</b> || cardinal || aMainRecord : IwbMainRecord || | | scope="row" | <b>FixedFormID</b> || cardinal || aMainRecord : IwbMainRecord || Returns the local FormID of the record (so local records will not have a load-order prefix e.g. 08FFFFFF -> 00FFFFFF) | ||
|- align="left" style="background-color: #EEEEEE" | |- align="left" style="background-color: #EEEEEE" | ||
| scope="row" | <b>FormID</b> || cardinal || aMainRecord : IwbMainRecord || Obtains the FormID of the record | | scope="row" | <b>FormID</b> || cardinal || aMainRecord : IwbMainRecord || Obtains the FormID of the record | ||
Line 117: | Line 117: | ||
| scope="row" | <b>GetIsESM</b> || boolean || file : IwbFile || Indicates if the plugin is an ESM file | | scope="row" | <b>GetIsESM</b> || boolean || file : IwbFile || Indicates if the plugin is an ESM file | ||
|- align="left" style="background-color: #F8F8F8" | |- align="left" style="background-color: #F8F8F8" | ||
| scope="row" | <b>GetIsInitiallyDisabled</b> || boolean || mainrecord : IwbMainRecord || | | scope="row" | <b>GetIsInitiallyDisabled</b> || boolean || mainrecord : IwbMainRecord || Returns the value of the initially disabled flag on the specified record as a boolean | ||
|- align="left" style="background-color: #EEEEEE" | |- align="left" style="background-color: #EEEEEE" | ||
| scope="row" | <b>GetIsPersistent</b> || boolean || mainrecord : IwbMainRecord || | | scope="row" | <b>GetIsPersistent</b> || boolean || mainrecord : IwbMainRecord || Returns the value of the persistent flag on the specified record as a boolean | ||
|- align="left" style="background-color: #F8F8F8" | |- align="left" style="background-color: #F8F8F8" | ||
| scope="row" | <b>GetIsVisibleWhenDistant</b> || boolean || mainrecord : IwbMainRecord || | | scope="row" | <b>GetIsVisibleWhenDistant</b> || boolean || mainrecord : IwbMainRecord || Returns the value of the visible when distant flag on the specified record as a boolean | ||
|- align="left" style="background-color: #EEEEEE" | |- align="left" style="background-color: #EEEEEE" | ||
| scope="row" | <b>GetLoadOrder</b> || cardinal || file : IwbFile || Gets the global load order of the file | | scope="row" | <b>GetLoadOrder</b> || cardinal || file : IwbFile || Gets the global load order of the file | ||
Line 143: | Line 143: | ||
| scope="row" | <b>InsertElement</b> || || container : IwbContainer , position : integer , element : IwbElement || Inserts an existing element inside a collection by position | | scope="row" | <b>InsertElement</b> || || container : IwbContainer , position : integer , element : IwbElement || Inserts an existing element inside a collection by position | ||
|- align="left" style="background-color: #EEEEEE" | |- align="left" style="background-color: #EEEEEE" | ||
| scope="row" | <b>IsEditable</b> || boolean || element : IwbElement || | | scope="row" | <b>IsEditable</b> || boolean || element : IwbElement || Returns true if the record can be edited by TES5Edit (false for Bethesda master files) | ||
|- align="left" style="background-color: #F8F8F8" | |- align="left" style="background-color: #F8F8F8" | ||
| scope="row" | <b>IsInjected</b> || boolean || element : IwbElement || | | scope="row" | <b>IsInjected</b> || boolean || element : IwbElement || Returns true if the record has been injected into another file | ||
|- align="left" style="background-color: #EEEEEE" | |- align="left" style="background-color: #EEEEEE" | ||
| scope="row" | <b>IsMaster</b> || boolean || record : IwbMainRecord || | | scope="row" | <b>IsMaster</b> || boolean || record : IwbMainRecord || Returns true if the record is not an override for an already existing record | ||
|- align="left" style="background-color: #F8F8F8" | |- align="left" style="background-color: #F8F8F8" | ||
| scope="row" | <b>IsWinningOverride</b> || boolean || record : IwbMainRecord || Checks whether or not the record is the highest override loaded | | scope="row" | <b>IsWinningOverride</b> || boolean || record : IwbMainRecord || Checks whether or not the record is the highest override loaded | ||
Line 157: | Line 157: | ||
| scope="row" | <b>LinksTo</b> || IwbElement || element : IwbElement || Obtains the referenced element | | scope="row" | <b>LinksTo</b> || IwbElement || element : IwbElement || Obtains the referenced element | ||
|- align="left" style="background-color: #F8F8F8" | |- align="left" style="background-color: #F8F8F8" | ||
| scope="row" | <b>LoadOrderFormIDtoFileFormID</b> || cardinal || file : IwbFile , aFormID : cardinal || | | scope="row" | <b>LoadOrderFormIDtoFileFormID</b> || cardinal || file : IwbFile , aFormID : cardinal || Converts a FormID from the LoadOrder to the File Format. This means removing the formID prefix from local formIDs. | ||
|- align="left" style="background-color: #EEEEEE" | |- align="left" style="background-color: #EEEEEE" | ||
| scope="row" | <b>MainRecordByEditorID</b> || IwbMainRecord || group : IwbGroupRecord || Does not work for every case because it's inefficient | | scope="row" | <b>MainRecordByEditorID</b> || IwbMainRecord || group : IwbGroupRecord || Does not work for every case because it's inefficient | ||
Line 163: | Line 163: | ||
| scope="row" | <b>Master</b> || IInterface || record : IwbMainRecord || | | scope="row" | <b>Master</b> || IInterface || record : IwbMainRecord || | ||
|- align="left" style="background-color: #EEEEEE" | |- align="left" style="background-color: #EEEEEE" | ||
| scope="row" | <b>MasterByIndex</b> || IInterface || file : IwbFile , index : integer || | | scope="row" | <b>MasterByIndex</b> || IInterface || file : IwbFile , index : integer || Returns the master file at the specified index from the specified file | ||
|- align="left" style="background-color: #F8F8F8" | |- align="left" style="background-color: #F8F8F8" | ||
| scope="row" | <b>MasterCount</b> || cardinal || file : IwbFile || | | scope="row" | <b>MasterCount</b> || cardinal || file : IwbFile || Returns the number of master files the specified file requires | ||
|- align="left" style="background-color: #EEEEEE" | |- align="left" style="background-color: #EEEEEE" | ||
| scope="row" | <b>MasterOrSelf</b> || IwbMainRecord || record : IwbMainRecord || | | scope="row" | <b>MasterOrSelf</b> || IwbMainRecord || record : IwbMainRecord || Returns the master record for the given record when used on override records | ||
|- align="left" style="background-color: #F8F8F8" | |- align="left" style="background-color: #F8F8F8" | ||
| scope="row" | <b>MoveDown</b> || || element : IwbElement || Moves the element down | | scope="row" | <b>MoveDown</b> || || element : IwbElement || Moves the element down (if the element is in a dtSubRecordArray or dtArray) | ||
|- align="left" style="background-color: #EEEEEE" | |- align="left" style="background-color: #EEEEEE" | ||
| scope="row" | <b>MoveUp</b> || || element : IwbElement || Moves the element up | | scope="row" | <b>MoveUp</b> || || element : IwbElement || Moves the element up (if the element is in a dtSubRecordArray or dtArray) | ||
|- align="left" style="background-color: #F8F8F8" | |- align="left" style="background-color: #F8F8F8" | ||
| scope="row" | <b>Name</b> || || element : IwbElement || Obtains the name of the element | | scope="row" | <b>Name</b> || || element : IwbElement || Obtains the name of the element | ||
Line 179: | Line 179: | ||
| scope="row" | <b>OverrideCount</b> || cardinal || record : IwbMainRecord || Provides a value for the number of overrides there are for a given record | | scope="row" | <b>OverrideCount</b> || cardinal || record : IwbMainRecord || Provides a value for the number of overrides there are for a given record | ||
|- align="left" style="background-color: #EEEEEE" | |- align="left" style="background-color: #EEEEEE" | ||
| scope="row" | <b>Path</b> || string || element : IwbElement || | | scope="row" | <b>Path</b> || string || element : IwbElement || Returns the path of the specified element. | ||
|- align="left" style="background-color: #F8F8F8" | |- align="left" style="background-color: #F8F8F8" | ||
| scope="row" | <b>RecordByEditorID</b> || IwbMainRecord || file : IwbFile , editorid : string || | | scope="row" | <b>RecordByEditorID</b> || IwbMainRecord || file : IwbFile , editorid : string || | ||
|- align="left" style="background-color: #EEEEEE" | |- align="left" style="background-color: #EEEEEE" | ||
| scope="row" | <b>RecordByFormID</b> || IwbMainRecord || file : IwbFile , formid : integer , aAllowInjected : boolean || | | scope="row" | <b>RecordByFormID</b> || IwbMainRecord || file : IwbFile , formid : integer , aAllowInjected : boolean || Will return the record with the specified FormID in the specified file, if it exists. | ||
|- align="left" style="background-color: #F8F8F8" | |- align="left" style="background-color: #F8F8F8" | ||
| scope="row" | <b>RecordByIndex</b> || IwbMainRecord || file : IwbFile , index : integer || | | scope="row" | <b>RecordByIndex</b> || IwbMainRecord || file : IwbFile , index : integer || Returns the reocrd at the specified index in the specified file. | ||
|- align="left" style="background-color: #EEEEEE" | |- align="left" style="background-color: #EEEEEE" | ||
| scope="row" | <b>RecordCount</b> || cardinal || file : IwbFile || Returns a value corresponding to the number of records in a file | | scope="row" | <b>RecordCount</b> || cardinal || file : IwbFile || Returns a value corresponding to the number of records in a file | ||
|- align="left" style="background-color: #F8F8F8" | |- align="left" style="background-color: #F8F8F8" | ||
| scope="row" | <b>ReferencedByCount</b> || cardinal || record : IwbMainRecord || | | scope="row" | <b>ReferencedByCount</b> || cardinal || record : IwbMainRecord || Returns the number of records that reference the input record. | ||
|- align="left" style="background-color: #EEEEEE" | |- align="left" style="background-color: #EEEEEE" | ||
| scope="row" | <b>ReferencedByIndex</b> || IwbMainRecord || record : IwbMainRecord , index : integer || | | scope="row" | <b>ReferencedByIndex</b> || IwbMainRecord || record : IwbMainRecord , index : integer || Returns the IwbMainRecord reference to the given record at the entered index. | ||
|- align="left" style="background-color: #F8F8F8" | |- align="left" style="background-color: #F8F8F8" | ||
| scope="row" | <b>Remove</b> || || element : IwbElement || Removes an element | | scope="row" | <b>Remove</b> || || element : IwbElement || Removes an element. | ||
|- align="left" style="background-color: #EEEEEE" | |- align="left" style="background-color: #EEEEEE" | ||
| scope="row" | <b>RemoveByIndex</b> || IwbElement || container : IwbContainer , index : integer , aMarkModified : boolean || | | scope="row" | <b>RemoveByIndex</b> || IwbElement || container : IwbContainer , index : integer , aMarkModified : boolean || | ||
Line 199: | Line 199: | ||
| scope="row" | <b>RemoveElement</b> || IwbElement || container : IwbContainer , element : IwbElement || | | scope="row" | <b>RemoveElement</b> || IwbElement || container : IwbContainer , element : IwbElement || | ||
|- align="left" style="background-color: #EEEEEE" | |- align="left" style="background-color: #EEEEEE" | ||
| scope="row" | <b>RemoveNode</b> || boolean || node : IwbElement || Removes the node from the file | | scope="row" | <b>RemoveNode</b> || boolean || node : IwbElement || Removes the node from the file. Use this instead of Remove/RemoveElement to avoid errors when removing elements selected by and visible to the user. | ||
|- align="left" style="background-color: #F8F8F8" | |- align="left" style="background-color: #F8F8F8" | ||
| scope="row" | <b>ResourceCopy</b> || || container : IwbContainer , fileName : string , pathOut : string , containerIndex : integer || | | scope="row" | <b>ResourceCopy</b> || || container : IwbContainer , fileName : string , pathOut : string , containerIndex : integer || | ||
Line 223: | Line 223: | ||
| scope="row" | <b>SetIsESM</b> || || file : IwbFile , value : boolean || Enables/disbles ESM flag for a file | | scope="row" | <b>SetIsESM</b> || || file : IwbFile , value : boolean || Enables/disbles ESM flag for a file | ||
|- align="left" style="background-color: #EEEEEE" | |- align="left" style="background-color: #EEEEEE" | ||
| scope="row" | <b>SetIsInitiallyDisabled</b> || || record : IwbMainRecord , value : boolean || | | scope="row" | <b>SetIsInitiallyDisabled</b> || || record : IwbMainRecord , value : boolean || Enables/disables the initially disabled flag for a record. | ||
|- align="left" style="background-color: #F8F8F8" | |- align="left" style="background-color: #F8F8F8" | ||
| scope="row" | <b>SetIsPersistent</b> || || record : IwbMainRecord , value : boolean || | | scope="row" | <b>SetIsPersistent</b> || || record : IwbMainRecord , value : boolean || Enables/disables the persistent flag for a record. | ||
|- align="left" style="background-color: #EEEEEE" | |- align="left" style="background-color: #EEEEEE" | ||
| scope="row" | <b>SetIsVisibleWhenDistant</b> || || record : IwbMainRecord , value : boolean || | | scope="row" | <b>SetIsVisibleWhenDistant</b> || || record : IwbMainRecord , value : boolean || Enables/disables the visible when distant flag for a record. | ||
|- align="left" style="background-color: #F8F8F8" | |- align="left" style="background-color: #F8F8F8" | ||
| scope="row" | <b>SetLoadOrderFormID</b> || || record : IwbMainRecord , loadOrderFormId : cardinal || Changes the 8-digit hexadecimal Form ID for a record | | scope="row" | <b>SetLoadOrderFormID</b> || || record : IwbMainRecord , loadOrderFormId : cardinal || Changes the 8-digit hexadecimal Form ID for a record | ||
Line 237: | Line 237: | ||
| scope="row" | <b>Signature</b> || string || record : IwbMainRecord || Gets the signature of a record | | scope="row" | <b>Signature</b> || string || record : IwbMainRecord || Gets the signature of a record | ||
|- align="left" style="background-color: #F8F8F8" | |- align="left" style="background-color: #F8F8F8" | ||
| scope="row" | <b>SortKey</b> || string || element : IwbElement, aExtended: boolean || | | scope="row" | <b>SortKey</b> || string || element : IwbElement, aExtended: boolean || Outputs a string unique to the element entered. This can be used for sorting elements or for comparing them. E.g. You could compare the SortKey for two elements in records which override each other to see if they are different from each other. | ||
|- align="left" style="background-color: #EEEEEE" | |- align="left" style="background-color: #EEEEEE" | ||
| scope="row" | <b>SortMasters</b> || || file : IwbFile || Attempts to sort the masters for a file by their load order | | scope="row" | <b>SortMasters</b> || || file : IwbFile || Attempts to sort the masters for a file by their load order | ||
|- align="left" style="background-color: #F8F8F8" | |- align="left" style="background-color: #F8F8F8" | ||
| scope="row" | <b>wbCopyElementToFile</b> || IwbElement || element : IwbElement , file : IwbFile , aAsNew : boolean , aDeepCopy : boolean || | | scope="row" | <b>wbCopyElementToFile</b> || IwbElement || element : IwbElement , file : IwbFile , aAsNew : boolean , aDeepCopy : boolean || Copies an IwbMainRecord, IwbGroupRecord, or IwbContainer to the specified file. The aAsNew boolean controls whether or not you're copying the record as an override record. | ||
|- align="left" style="background-color: #EEEEEE" | |- align="left" style="background-color: #EEEEEE" | ||
| scope="row" | <b>wbCopyElementToRecord</b> || IwbElement || element : IwbElement , aMainRecord : IwbMainRecord , aAsNew : boolean , aDeepCopy : boolean || | | scope="row" | <b>wbCopyElementToRecord</b> || IwbElement || element : IwbElement , aMainRecord : IwbMainRecord , aAsNew : boolean , aDeepCopy : boolean || Copies an element to a record. E.g. the "conditions" element on a COBJ record, or a faction from an NPC_ record. | ||
|- align="left" style="background-color: #F8F8F8" | |- align="left" style="background-color: #F8F8F8" | ||
| scope="row" | <b>WinningOverride</b> || IwbMainRecord || record : IwbMainRecord || Will return the winning override record | | scope="row" | <b>WinningOverride</b> || IwbMainRecord || record : IwbMainRecord || Will return the winning override record |