SpinTires XML files Inheritance

SpinTires XML files Inheritance
XML files Spintires no different from ordinary XML files and can be read by any third party software. But SpinTires uses the special rules of reading data from XML files.


SpinTires XML templates are used to avoid copying. For example, the wheels of the truck are basically identical, however, each described by its own XML node. To prevent copying the attributes in each node, the wheel's template is created in a special file called "_templates":

There are global templates with predefined templates. They can be enabled by adding, for example, an attribute ="trucks". All these files are in folder "\Media\_templates".
Each wheel uses this template (an attribute called "_template"):

<Wheel _template="RearWheel" HardpointX="-0.49" />
<Wheel _template="RearWheel" HardpointX="-0.49" RightSide="true" />
<Wheel _template="RearWheel" HardpointX="-1.93" />
<Wheel _template="RearWheel" HardpointX="-1.93" RightSide="true" />
XML branch may use only those templates that are described as a child of node node with the same name. Remember that the wheels use template "RearWheel", which is a child of node of the branch Wheel in the section "_templates".
Thus, it appears almost the same as copying all attributes in each individual XML node. The node that uses the template can override any attribute of a particular template. The node's hierarchy, as well as the hierarchy of attributes is copied by the system template.


SpinTires XML file can inherit from another file:

<_parent File="kamaz6520" />

This is approximately the same as the global template for the entire file. It turns out that all the attributes and nodes are loaded from the file "kamaz6520.xml" then the attributes and branches from the current file (if they are there) are merged at the top (overridden).

This, for example, facilitates the support of different trucks, which are slightly different from each other. Inheritance also affects the behavior of the model directly in the game:

  • All Steam game achievements work with all inherited trucks. If truck B has a row

    <_parent, File="A" />

    The player can get all the same achievements on the truck B, and truck A.
  • SpinTires truck addon requirements and addons exclude work for all included addons. For example, the string


    also exclude B, if B has a row

    <_parent, File="A" />

    And requirement

    <RequiredAddon Types="A" />

    Also true for B if B has all the same string

    <_parent, File="A" />
  • Inheritance applies to all model properties.


If the node of inherited XML file contains the string


Its properties and attributes will not be copied from the parent file. For example, if your truck mod has 4 wheels instead of 6, you add these 2 extra wheels with a string



If the node of inherited XML file contains the string


Then its attributes and child nodes will not be copied from the parent file. For example, if your truck mod has absolutely other wheels, you use "_noinherit" to not to give the parent file to override any settings of the mod.

 Views: 1526
 2016-03-29 11:58:22

Read also

Compact guide on migrating of old mods to the new version of SpinTires

A small manual on editing XML files SpinTires truck

SpinTires modding: textures and what to do with them

Detailed Spintires mod creating guide

Add comment

Top users