Element tree

From Multi Theft Auto: Wiki
Revision as of 01:01, 24 May 2006 by EAi (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

MTA uses a so-called element tree to store the elements that make up the map. This is directly related to the XML map file's layout, although it can be changed at run-time by scripts.

If you are familiar with the concept of trees in computer-science, this should be easy to understand. If you are not, think of it like a family tree - except everyone only has a single parent. Every element has a parent element. This element is the element that it is contained within in the map file. For example:


In this example, the vehicle element's parent is the marker element. As such, we call the vehicle element a child element of the marker element.

All elements in a map are contained within the map node. We call this the root node, and it has to exist in every map file.

Elements can have as many children as they like. This does not directly affect the map in any way, but it comes in to its own when combined with the scripting system.

If you call a set... function on a node of the element tree, the function will affect every element within it (that it can work on).

So, the following code would set the size of every marker (the only type of element the setMarkerSize function can work on) that is below the root element to 2.5.

setMarkerSize ( getRootElement(), 2.5 )

The same can be done on any element, it is not restricted to the root element.