18,700
edits
(overall copy-edit; lowered all headers one level so that level 1 isn't being used (that is reserved for the article title); grammar edit to first half of article) |
(grammar edit to rest of article) |
||
Line 1: | Line 1: | ||
This page lists all XmlTools commands with examples. It is the full version of the | This page lists all XmlTools commands with examples. It is the full version of the documentation of XmlTools options found on the [[XmlTools|main page]]. The main page also offers a beginner's guide to this program's syntax and links to pages that explain the concepts behind XML modding. | ||
{{TOClimit|3}} | {{TOClimit|3}} | ||
Line 10: | Line 10: | ||
This operation allows you to add new XML values to an existing XML element that contains a list of values. The values should be space-separated and contained within quotes. | This operation allows you to add new XML values to an existing XML element that contains a list of values. The values should be space-separated and contained within quotes. | ||
Oni's game data contains various bitsets that are used to indicate the on/off status of attributes that can pertain to that object. For instance, characters in the game can have various flags such as Unkillable turned on for them. In OniSplit's XML output of this data, the flags are given names and listed within quotes as a single string. --add-values and --remove-values were designed to edit these XML representations of bitsets. | Oni's game data contains various bitsets that are used to indicate the on/off status of attributes that can pertain to that object. For instance, characters in the game can have various flags such as Unkillable turned on for them. In OniSplit's XML output of this data, the flags are given names and listed within quotes as a single string. '''--add-values''' and '''--remove-values''' were designed to edit these XML representations of bitsets. | ||
Usage: | Usage: | ||
Line 16: | Line 16: | ||
====Example==== | ====Example==== | ||
Let's say you want to add the Unkillable and | Let's say you want to add the Unkillable and NonCombatant flags to character A_L18. | ||
Line 255: | Line 255: | ||
====Examples==== | ====Examples==== | ||
=====Example 1===== | =====Example 1===== | ||
Let's say you have a level built in a 3D modeling program and you have already set the positions in the BINACBJOCharacter file for all the characters that are to be spawned during the gameplay. However, for some reason you need to change the position of the level in the modeling program, which means that the character spawn locations are now incorrect. --update-elements provides the | Let's say you have a level built in a 3D modeling program and you have already set the positions in the BINACBJOCharacter file for all the characters that are to be spawned during the gameplay. However, for some reason you need to change the position of the level in the modeling program, which means that the character spawn locations are now incorrect. '''--update-elements''' provides the means for correcting them. | ||
Let's say that you know that the difference between the old level's position and the new level's position is, in Oni's world units, {130, 80, 0} | Let's say that you know that the (x, y, z) difference between the old level's position and the new level's position is, in Oni's world units, {130, 80, 0}. Those offsets can be deducted from each spawn location. | ||
'''XmlTools command:''' | '''XmlTools command:''' | ||
Line 389: | Line 389: | ||
====Example==== | ====Example==== | ||
Let's say you want to invert the helicopter animation from Oni's final level. | Let's say you want to invert the helicopter animation from Oni's final level. You'll notice that the helicopter comes up from below to land on the satellite dish platform, and then it goes down again. If we invert the helicopter animation, it will come down from above, and then go back up again (which is exactly what was done in the Old China mod). | ||
For simplicity we will only edit one part of the helicopter animation: 'heli_interior09' and its Translation (position) element. Please note that to correctly invert the animation, you will need to invert the Rotation element too. | For simplicity we will only edit one part of the helicopter animation: 'heli_interior09' and its Translation (position) element. Please note that to correctly invert the animation, you will need to invert the Rotation element too. | ||
Line 459: | Line 459: | ||
==Patch file operations== | ==Patch file operations== | ||
XmlTools has a special set of commands that can be listed within a plain-text file to be executed all at once. | XmlTools has a special set of commands that can be listed within a plain-text file to be executed all at once. These commands were designed for use with the AE Installer and revolve around making larger or more complex changes to the data that can only be easily conveyed to XmlTools in a text file. Since one of the following commands allows you to use any of the operations listed in the "Command-line operations" section, all the above functionality is accessible here too. See the [[XmlTools|main page]] for the syntax of supplying a patch file to XmlTools. | ||
===@XML_TOOLS=== | ===@XML_TOOLS=== | ||
====Description==== | ====Description==== | ||
This operation allows to specify options related | This operation allows you to specify options related to running XmlTools. Currently the only option available is "Version", which allows you to supply the minimum version of XmlTools that is required to apply the patch file. | ||
Usage: | Usage: | ||
Line 474: | Line 474: | ||
<pre>@XML_TOOLS Version "2.0"</pre> | <pre>@XML_TOOLS Version "2.0"</pre> | ||
Note that | Note that "2.0" means that it is also compatible with XmlTools 2.0a, 2.0b, etc. | ||
===@ADD_INSIDE_NODES=== | ===@ADD_INSIDE_NODES=== | ||
====Description==== | ====Description==== | ||
This operation allows to insert new XML | This operation allows you to insert a block of new XML into existing XML nodes. The XML to be inserted must be wrapped in <tt><xml></tt>...<tt></xml></tt> tags as seen below. | ||
Usage: | Usage: | ||
Line 491: | Line 491: | ||
====Example==== | ====Example==== | ||
Let's say | Let's say you want to add a new glass particle to the SWAT Griffin ONCC. | ||
'''XmlTools patch command:''' | '''XmlTools patch command:''' | ||
Line 504: | Line 504: | ||
{| style="margin: 1em auto 1em auto;" <!-- Centers table --> | {| style="margin: 1em auto 1em auto;" <!-- Centers table --> | ||
! style="width: 50%;" | XML | ! style="width: 50%;" | XML Before | ||
! style="width: 50%;" | XML After | ! style="width: 50%;" | XML After | ||
|- | |- | ||
| | | | ||
Line 546: | Line 546: | ||
===@REMOVE_NODES=== | ===@REMOVE_NODES=== | ||
====Description==== | ====Description==== | ||
This operation allows to remove existing XML nodes. | This operation allows you to remove existing XML nodes. | ||
Usage: | Usage: | ||
Line 552: | Line 552: | ||
====Example==== | ====Example==== | ||
Let's say | Let's say you want to remove the glass particle from the SWAT Griffin ONCC. | ||
'''XmlTools patch command:''' | '''XmlTools patch command:''' | ||
Line 558: | Line 558: | ||
{| style="margin: 1em auto 1em auto;" <!-- Centers table --> | {| style="margin: 1em auto 1em auto;" <!-- Centers table --> | ||
! style="width: 50%;" | XML | ! style="width: 50%;" | XML Before | ||
! style="width: 50%;" | XML After | ! style="width: 50%;" | XML After | ||
|- | |- | ||
| | | | ||
Line 600: | Line 600: | ||
===@COMMAND=== | ===@COMMAND=== | ||
====Description==== | ====Description==== | ||
This operation allows you to use any of the [[XmlTools#Command-line_operations|command line operations]] in a patch file. | This operation allows you to use any of the [[XmlTools#Command-line_operations|command-line operations]] in a patch file. | ||
Usage: | Usage: | ||
<tt>@COMMAND Options "Command line operation"</tt> | <tt>@COMMAND Options "Command line operation"</tt> | ||
Note: For command line input operations which use quotes ("") replace the double quotes with single quotes (<nowiki>''</nowiki>). If any XPath expression also includes single quotes you can double them to allow XmlTools to process the command. | Note: For command-line input operations which use quotes ("..."), replace the double quotes with single quotes (<nowiki>'...'</nowiki>). If any XPath expression also includes single quotes, you can double them (<nowiki>''...''</nowiki>) to allow XmlTools to process the command. | ||
====Example==== | ====Example==== | ||
Let's say | Let's say you want to perform the same operation as in the [[#Example|--add-values example]]: adding the Unkillable and NonCombatant flags to character A_L18. | ||
'''XmlTools patch command:''' | '''XmlTools patch command:''' | ||
@COMMAND Options "--add-values --new-val 'Unkillable NonCombatant' --xpath-expression '/Oni/Objects/CHAR[@Id=<nowiki>''3926''</nowiki>]/OSD/Flags' --files 'BINACJBOCharacter.xml'" | @COMMAND Options "--add-values --new-val 'Unkillable NonCombatant' --xpath-expression '/Oni/Objects/CHAR[@Id=<nowiki>''3926''</nowiki>]/OSD/Flags' --files 'BINACJBOCharacter.xml'" | ||
Note that in the XPath expression we replace each single quote by two single quotes | Note that in the XPath expression we replace each single quote by two single quotes, allowing XmlTools to differentiate from the single quotes used around command line options). | ||
The resulting XML file is exactly the same | The resulting XML file is exactly the same as in the [[#Example|--add-values example]]. | ||
===@CUSTOM_CODE=== | ===@CUSTOM_CODE=== | ||
====Description==== | ====Description==== | ||
This operation allows you to use [[wikipedia:JavaScript|JavaScript]] to edit XML. | This operation allows you to use [[wikipedia:JavaScript|JavaScript]] to edit XML. You can use this for complex logic and mathematical tasks which aren't supported by XmlTools' basic operations. <u>You should only use this option as a '''last resort'''</u> if you are using it for a [[Anniversary_Edition/Framework#XML_patching|patch mod]], because it is '''MUCH slower''' than all the other native options. Try to <u>optimize your code as much as possible</u>, as the complexity of the code has a large effect on the overall speed of XmlTools in running JavaScript. | ||
You can use this for complex | |||
<u>You should only use this option as '''last resort'''</u> if you are using it for [[Anniversary_Edition/Framework#XML_patching| | |||
Usage: | Usage: | ||
Line 635: | Line 631: | ||
<tt><nowiki></code></nowiki></tt> | <tt><nowiki></code></nowiki></tt> | ||
You can exit prematurely from the JavaScript code using the <tt>return</tt> keyword. It is also possible output JavaScript variables to the console using the echo function: <tt>echo(var);</tt>. This function allows you to debug the code that you develop. | You can exit prematurely from the JavaScript code using the <tt>return</tt> keyword. It is also possible to output JavaScript variables to the console using the "echo" function: <tt>echo(var);</tt>. This function allows you to debug the code that you develop. | ||
The <tt>$xmlData</tt> global variable contains the | The <tt>$xmlData</tt> global variable contains the contents of the XML file on disk. After you modify the XML, update this variable again with the new XML in order for XmlTools to update the file on disk, otherwise your changes will not take effect. | ||
XmlTools uses the [http://www.petetracey.com/jsxml/index.html JSXML XML Tools] JavaScript libraries to allow you to | XmlTools uses the [http://www.petetracey.com/jsxml/index.html JSXML XML Tools] JavaScript libraries to allow you to operate upon the XML. You can read its documentation on its [http://www.petetracey.com/jsxml/documentation.html website] or [http://script10k.oni2.net/documentation/xmltools/jsxml-documentation.htm here]. | ||
====Example==== | ====Example==== | ||
Let's say | Let's say you want to add one additional ammo clip and energy cell to all characters that are on the TCTF team. | ||
'''XmlTools patch command:''' | '''XmlTools patch command:''' | ||
Line 657: | Line 653: | ||
<span style="color:green">// Loop over all characters</span> | <span style="color:green">// Loop over all characters</span> | ||
for (var i=0; (charactersNode.childElement(i)); i++){ <span style="color:green">// | for (var i=0; (charactersNode.childElement(i)); i++){ <span style="color:green">// The condition checks if the 'i'th element exists (!= undefined)</span> | ||
var currChar=charactersNode.childElement(i); | var currChar=charactersNode.childElement(i); | ||
<span style="color:green">// Check if | <span style="color:green">// Check if team is TCTF</span> | ||
if(currChar.childElement("OSD").childElement("Team").text=="TCTF"){ | if(currChar.childElement("OSD").childElement("Team").text=="TCTF"){ | ||
Line 668: | Line 664: | ||
currCellsElement=currChar.childElement("OSD").childElement("Inventory").childElement("EnergyCell").childElement("Use"); | currCellsElement=currChar.childElement("OSD").childElement("Inventory").childElement("EnergyCell").childElement("Use"); | ||
<span style="color:green">// Add | <span style="color:green">// Add 1 to the current amount of ammo and cells to use</span> | ||
currAmmoElement.text=parseInt(currAmmoElement.text)+1; | currAmmoElement.text=parseInt(currAmmoElement.text)+1; | ||
currCellsElement.text=parseInt(currCellsElement.text)+1; | currCellsElement.text=parseInt(currCellsElement.text)+1; | ||
Line 674: | Line 670: | ||
} | } | ||
$xmlData=myBuilder.generateXML(); <span style="color:green">// | $xmlData=myBuilder.generateXML(); <span style="color:green">// Update the global variable with the new XML to save changes</span> | ||
<nowiki></code></nowiki> | <nowiki></code></nowiki> | ||
{| style="margin: 1em auto 1em auto;" <!-- Centers table --> | {| style="margin: 1em auto 1em auto;" <!-- Centers table --> | ||
! style="width: 50%;" | XML | ! style="width: 50%;" | XML Before | ||
! style="width: 50%;" | XML After | ! style="width: 50%;" | XML After | ||
|- | |- | ||
| | | |