Custom Data Types - npruehs/tome-editor GitHub Wiki

Most projects will require more than the few built-in data types. A popular example is using enumerations for creating custom value ranges, such as damage types or difficulty levels.

In Tome, you can create your own enumerations and specify their values.

The Custom Types window will show you all types you've defined for your project. For enumerations, it will also show the members of the respective enumeration. For lists, it will show you the type of the list items, and for maps the key and value types.

Custom Types

Adding Enumerations

In order to use an enumeration for your game, you need to create one first.

  1. In the main window, click Fields > Manage Custom Types...
  2. In the Custom Types window, click Custom Types > New Enumeration...
  3. In the Enumeration window, specify a name for the new type.
  4. In same window, click New Member to add values to the enumeration.
  5. After you have added all values, specify the file to add the enumeration to and close the Enumeration window by clicking OK.
  6. Close the Custom Types window.

Now, your new type will be available when creating new fields, providing combo boxes for specifying field values.

Enumerations are much less error-prone for designers than strings. Whenever you've got a limited set of values, such as armor types (e.g. mail, leather, cloth), prefer enumerations over strings.

Enumeration Window

Adding Lists

You can also create your own list types.

  1. In the main window, click Fields > Manage Custom Types...
  2. In the Custom Types window, click Custom Types > New List...
  3. In the List window, specify a name and an item type for the new list type.
  4. Specify the file to add the new list to.
  5. Close the List window by clicking OK.
  6. Close the Custom Types window.

Nested lists are not supported.

List Window

Adding Maps

Since Tome 0.5, you can also create your own map types.

  1. In the main window, click Fields > Manage Custom Types...
  2. In the Custom Types window, click Custom Types > New Map...
  3. In the Map window, specify a name, key type and value type for the new map type.
  4. Specify the file to add the new map to.
  5. Close the Map window by clicking OK.
  6. Close the Custom Types window.

Nested maps are not supported.

Map Window

Adding Derived Types

Since Tome 0.7, you can define your own types derived from built-in types such as Integer or String. Tome allows you to put special constraints on these derived types called facets. With type facets, you can specify the minimum value of an integer, the maximum length of a string, or the required parent of a record reference, just to name a few.

When editing record field values, these facets will be shown in the textual description of the field, and will automatically be enforced by Tome. This allows you to increase data integrity throughout your project.

  1. In the main window, click Fields > Manage Custom Types...
  2. In the Custom Types window, click Custom Types > New Derived Type...
  3. In the Derived Type window, specify a name and a base type for the new derived type.
  4. Specify the file to add the new derived type to.
  5. Set any facet values for your new derived type, such as the minimum value.
  6. Close the Derived Type window by clicking OK.
  7. Close the Custom Types window.

The following facets are available:

Facet Type Minimum Tome Version Description
Localized String 0.8 Field value is exported using the .texportvloc template instead of the .texportv template.
Minimum Value Integer 0.6 Field value must not be less than the specified minimum value.
Maximum Value Integer, Real 0.6 Field value must not be greater than the specified minimum value.
Maximum Length String 0.6 Field value must not be longer than the specified number of characters.
Required Ancestor Reference 0.6 Field value must denote any child or descendant of the specified record.
Removed File Prefix File 0.9 Whenever picking a file, remove this prefix for setting the actual field value (e.g. directory names).
Removed File Suffix File 0.9 Whenever picking a file, remove this suffix for setting the actual field value (e.g. file extension).

Editing Types

You can modify existing custom types later.

  1. In the main window, click Fields > Manage Custom Types...
  2. In the Custom Types window, double-click any existing type.
  3. Update your custom type as desired.
  4. Close the window by clicking OK.
  5. Close the Custom Types window.

Deleting Types

Custom types can be deleted again from the Custom Types window.

  1. In the main window, click Fields > Manage Custom Types...
  2. In the Custom Types window, select any type and click Custom Types > Delete Custom Type.
  3. Close the Custom Types window.

Note that changing or deleting a type might invalidate any records using that type.

Next: Search