20,100
edits
Script 10k (talk | contribs) (changed javascript example to multiplication of the items instead of sum. Sum was a bad example since it can be achieved easily with a combination of XPath and --update-elements command which is a faster native approach) |
m (link fix) |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 555: | Line 555: | ||
'''XmlTools patch command:''' | '''XmlTools patch command:''' | ||
@REMOVE_NODES XPathExpression "/Oni/ONCP/Particles/ONCPParticle[Name = 'glass_break']" Files "ONCCgriffin_swat.xml" | @REMOVE_NODES XPathExpression "/Oni/ONCP/Particles/ONCPParticle[@Name = 'glass_break']" Files "ONCCgriffin_swat.xml" | ||
{| style="margin: 1em auto 1em auto;" <!-- Centers table --> | {| style="margin: 1em auto 1em auto;" <!-- Centers table --> | ||
| Line 619: | Line 619: | ||
===@CUSTOM_CODE=== | ===@CUSTOM_CODE=== | ||
====Description==== | ====Description==== | ||
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 [[ | 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 [[Making a patch mod|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. | ||
Usage: | Usage: | ||
| Line 635: | Line 635: | ||
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. | 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 | XmlTools uses the JSXML XML Tools (<nowiki>http://www.petetracey.com/jsxml/index.html</nowiki>, dead link) JavaScript libraries to allow you to operate upon the XML. You can read its documentation on its website (<nowiki>http://www.petetracey.com/jsxml/documentation.html</nowiki>, dead link) or [http://script10k.oni2.net/documentation/xmltools/jsxml-documentation.htm here]. | ||
====Example==== | ====Example==== | ||