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.
Adding Enumerations
In order to use an enumeration for your game, you need to create one first.
- In the main window, click Fields > Manage Custom Types...
- In the Custom Types window, click Custom Types > New Enumeration...
- In the Enumeration window, specify a name for the new type.
- In same window, click New Member to add values to the enumeration.
- After you have added all values, specify the file to add the enumeration to and close the Enumeration window by clicking OK.
- 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.
Adding Lists
You can also create your own list types.
- In the main window, click Fields > Manage Custom Types...
- In the Custom Types window, click Custom Types > New List...
- In the List window, specify a name and an item type for the new list type.
- Specify the file to add the new list to.
- Close the List window by clicking OK.
- Close the Custom Types window.
Nested lists are not supported.
Adding Maps
Since Tome 0.5, you can also create your own map types.
- In the main window, click Fields > Manage Custom Types...
- In the Custom Types window, click Custom Types > New Map...
- In the Map window, specify a name, key type and value type for the new map type.
- Specify the file to add the new map to.
- Close the Map window by clicking OK.
- Close the Custom Types window.
Nested maps are not supported.
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.
- In the main window, click Fields > Manage Custom Types...
- In the Custom Types window, click Custom Types > New Derived Type...
- In the Derived Type window, specify a name and a base type for the new derived type.
- Specify the file to add the new derived type to.
- Set any facet values for your new derived type, such as the minimum value.
- Close the Derived Type window by clicking OK.
- 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.
- In the main window, click Fields > Manage Custom Types...
- In the Custom Types window, double-click any existing type.
- Update your custom type as desired.
- Close the window by clicking OK.
- Close the Custom Types window.
Deleting Types
Custom types can be deleted again from the Custom Types window.
- In the main window, click Fields > Manage Custom Types...
- In the Custom Types window, select any type and click Custom Types > Delete Custom Type.
- Close the Custom Types window.
Note that changing or deleting a type might invalidate any records using that type.
Next: Search