Config File

The CustomOreGen config file is named CustomOreGen_Config.xml. It is written in XML and contains every detail of COG's ore generation. XML has a bit of a learning curve, so the basics are given here. To make the file easier to read and understand, use a text editor with syntax highlighting like Notepad++.

For quick navigation, the main features of the config file are Options, Conditions, and Distributions (Veins, Cloud, StandardGen, and Substitute). All of these make use of Expressions.

XML Basics
The config file is written in XML, a markup language with similar syntax to the HTML used in webpages. A full tutorial on XML is way outside the scope of this page, but the basics are simple enough. An XML document is broken up into elements, each of which can contain text or other elements. This creates a tree-like structure. Each element starts and ends with the element name in angle brackets: &lt;SomeElement&gt; This is the stuff inside the element &lt;/SomeElement&gt; If an element doesn't have anything inside it (which is pretty common), the start and end tags can be combined: &lt;SomeElement /&gt; An element with another element inside it might look like this: &lt;ParentElement&gt; &lt;ChildElement /&gt; &lt;/ParentElement&gt; White space doesn't matter, so these elements can be rearranged as needed: &lt;ParentElement&gt; &lt;ChildElement /&gt; &lt;/ParentElement&gt; XML comments begin with &quot;&quot;: &lt;!-- this is a comment - any program that reads this will ignore it --&gt;

In addition to their contents, elements can have attributes, listed as name/value pairs in the opening tag: &lt;SomeElement someAttribute='someValue' /&gt; CustomOreGen uses attributes very extensively.

Everything in XML is CASE SENSITIVE. Be very careful with capitalization.

Special XML features in COG
CustomOreGen has a specially written parser that includes some powerful features not found in standard xml.

Annotations
&lt;Description&gt; and &lt;Comment&gt; elements can be placed anywhere in the config file. &quot;Description&quot; may also be used as an attribute for any element. Collectively these can be used to attach text annotations to anything in the config file. Some Descriptions are kept and used internally, but most annotations are simply discarded after being read. Even so, the contents of these annotations still need to be simple text or valid XML.

Child Elements as Attributes
Attributes are interchangeable with child elements of the same name. For example, these two elements would be considered identical by the COG parser: &lt;Foo bar='biz' /&gt; &lt;Foo&gt; &lt;Bar&gt; biz &lt;/Bar&gt; &lt;/Foo&gt; The second &lt;Foo&gt; element doesn't technically have a &quot;bar&quot; attribute, but the COG parser considers the contents of the &lt;Bar&gt; element to be equivalent. This is possible because the COG config file has been carefully designed to avoid overlap between attribute names and &quot;real&quot; element names.

Expressions
Attributes may be set with expressions. The expression is evaluated and the result is used as the attribute value. For example, the &quot;bar&quot; attribute here is assigned the result of 6 times 7, i.e. 42: &lt;Foo bar=':= 6 * 7' /&gt; &lt;Foo&gt; &lt;Bar&gt;:= 6 * 7 &lt;/Bar&gt; &lt;/Foo&gt;

Conditions
Any part of the COG config file may be wrapped in a conditional element. Depending on the result of the condition, the contents of the conditional element will either be parsed as normal or discarded. For example, this Veins distribution will only be generated if the Redpower mod is installed: &lt;IfModInstalled name='mod_RedPowerWorld'&gt; &lt;Veins name='rpCopperVeins' block='rpores:5'/&gt; &lt;/IfModInstalled&gt;

Sections
The &lt;ConfigSection&gt; element can be used to group together related elements. These sections are purely aesthetic; all child elements and attributes of the section are considered to be children of its parent element. For example, these two elements would be considered identical by the COG parser: &lt;source lang=&quot;xml&quot;&gt; &lt;Foo bar='biz'&gt; &lt;Bat/&gt; &lt;/Foo&gt; &lt;Foo&gt; &lt;ConfigSection bar='biz'&gt; &lt;Bat/&gt; &lt;/ConfigSection&gt; &lt;/Foo&gt; The &quot;bar&quot; attribute and &quot;Bat&quot; child element in the second line are read by the COG parser as being the children of the &lt;Foo&gt; element.

Imports
Configuration data from other XML files can be included using a import element. This allows a configuration fragment such as distributions for a single mod to be packaged and distributed as its own file and then imported into the main config.

The COG Config File
The CustomOreGen config file is named CustomOreGen_Config.xml. A copy of the &quot;standard&quot; config is created in the /config folder when the mod is first installed. This is the global config file. A saved world can be given its own config by placing the file in the world save folder (i.e. saves/New World). A single dimension in a saved world can be given its own config by placing the file in the dimension subfolder (i.e. saves/New World/DIM-1 for the New World Nether).

In-game, COG loads the most specific configuration it can find for each dimension.

The root element of the config file must be a &lt;Config&gt; element. Everything else in the file (except xml comments) must be contained inside this element.

Within the root element distributions, options, and mystcraft symbols may be defined. These top-level elements are processed in the order in which they appear, so Options must be defined before any conditional elements or distributions that depend on them. Other than that there is no limit to the number or order of definitions in the config file.

Example
Here is an example config file containing one option and two distributions: &lt;Config&gt; &lt;!-- Generate Iron ore in veins around height 32 --&gt; &lt;Veins name='IronVeins' block='oreIron'&gt; &lt;Setting name='MotherlodeHeight' avg='32' range='16'/&gt; &lt;/Veins&gt; &lt;!-- The player can set the value of this option independently in each world --&gt; &lt;OptionChoice name='debugDist'&gt; &lt;Choice value='true'/&gt; &lt;Choice value='false'/&gt; &lt;/OptionChoice&gt; &lt;!-- If &quot;debugDist&quot; is true, generate red wool in veins around height 150 --&gt; &lt;IfChoice name='debugDist' value='true'&gt; &lt;Veins name='TestVeins' block='cloth:14'&gt; &lt;Setting name='MotherlodeHeight' avg='150' range='16'/&gt; &lt;Replaces block='air'/&gt; &lt;/Veins&gt; &lt;/IfChoice&gt; &lt;/Config&gt;