My current goal is to create a mod that's like Weapon Labs but doesn't require any weapons to actually be defined in the mod's XML. All the weapons will get their characteristics from modified vanilla, extension, and mod weapons using typGetXML and typCreate.
API 23:
http://multiverse.kronosaur.com/news.hexm?id=1063
XML Manipulation & Override
Another major feature in 1.5 is the ability to modify the XML for a given type. This is a feature based on suggestions from this forum thread.
The basic recipe looks like this:
In the root element of your extension (<TranscendenceExtension>), add usesXML="true". This tells the engine that you need the XML for all the types to be kept around for you.
In <OnGlobalTypesInit>, you may use a new function, typGetXML to get the XML for a type that you wish to override.
There are new functions that manipulate the XML returned by typGetXML. For example, you can set attributes or add elements.
Once you've manipulated the XML, you may call typCreate to dynamically create a new type or override an existing type.
Here is an example:
...
<OnGlobalTypesInit>
(block (cannonXML)
; Get the XML for the recoilless cannon
(setq cannonXML (typGetXML &itRecoillessCannon;))
; Change the name of the item
(xmlSetAttribute cannonXML 'name "my recoilless cannon")
; Redefine
(typCreate &itRecoillessCannon; cannonXML)
)
</OnGlobalTypesInit>
...
XML Manipulation Functions
There are several new functions that allow you to manipulate the XML returned by typGetXML:
(xmlAppendSubElement xml xmlToAdd [index]) -> True/Nil
(xmlAppendText xml text [index]) -> True/Nil
(xmlCreate xml) -> xml
(xmlDeleteSubElement xml index) -> True/Nil
(xmlGetAttrib xml attrib) -> value
(xmlGetAttribList xml) -> list of attribs
(xmlGetSubElement xml tag|index) -> xml
(xmlGetSubElementCount xml) -> number of sub-elements
(xmlGetSubElementList xml [tag]) -> list of xml
(xmlGetText xml [index]) -> text
(xmlGetTag xml) -> tag
(xmlSetAttrib xml attrib value) -> value
(xmlSetText xml text [index]) -> True/Nil
Warnings & Precautions
This functionality gives you a powerful new way to override the core XML, but it requires thought and finesse to implement properly.