Skip to end of metadata
Go to start of metadata


We have a generic interface for parsing and translating XML files into Lua files (in the future we'll also be able to go the other way).

In order to do this simply, we use an XML file as a definition format that declares what kinds of XML is included in a file, and what kind of Lua to create from that XML. This format includes some simple validation methods to ensure that the data expected is the data that is received.

We distinguish between three kinds of data: properties, arrays, and tables.

A table represents a Lua based table:

In an XML data file this table would look like so:

In an XML definition file this table would look like so:

Each element can be marked as

in the definition file to declare that it is not required.

There are two types of arrays; one is a simple group of element, like the Lua array:

In the XML data file this will might like so:

In the data description file this would look like so:


Another type of array is an array of tables; in Lua:

And in the XML data file:

And in the definition file:

Loading and Saving a Table from Lua:

If you have a Lua table that needs to be initialized, one can simply do the following:

In practice, I would suggest that we keep definition files with the scripts that use them, and the data files in a directory that is not the Scripts directory; which directory this is, is yet to be determined.

And to save a table from Lua:

Data types

The following data types are available, and can be set wherever a "type" attribute is present in the definition file:

  • Vec3 - in XML it's

    , and in Lua it's

  • float - a floating point number
  • int - an integer
  • string - a string
  • bool - a boolean value


A definition file:

A data file for the above definition:


For properties of type string, an optional Enum definition has been added. Property values will be validated against the Enum.


Enum support for other datatypes can be added, if necessary.

  • No labels