CardMaker Tutorial: References: Defines
This guide covers the creation and usage of defines. They are not very complex so there is not much to this! Be sure you have a decent understanding of references before you work with defines.
- A define is a value that is available across your entire reference. Usually anything referenced with @[column name] must exist in the current row of your reference.
With a define you can create values that can be referenced independent of the row. Maybe there are a number of constant values in your game that you want to easily tweak across multiple cards...
This functionality is best used to save you a lot of trouble when working with FormattedText Elements. They can be very bulky and contain a lot of duplicated information to embed graphics.
- Creating a defines file is fairly easy. Name it the same as your reference file with _defines appended to the name -- Example:
Reference File: data.csv
Define File: data_defines.csv
- The file should be located in the same folder as your reference.
- The content of the define file (also a CSV like the reference) is as follows:
- Column 1: Define Name
- Column 2: Define Value
- Row 1: You can name the columns whatever but I recommend: Define and Value
- As with references you can even nest a define to reference other defines. (see the fourth row)
- That is just about all there is to defines. You can use them just like a reference value with @[column name].
- Other Ideas / Uses
- Reduce FormattedText Clutter
With this you can easily reference the icon in any FormattedText element with just @[factionImg]. If you reference factionImg in multiple places you can tweak its configuration in just a single spot.
Define Value factionImg <img=images\faction_empire.bmp;.90;0;3>
- Reduce Clutter Overall + Nesting
Define Value tokenActionCost 3 tokens tokenActionMessage Each Action you take costs @[tokenActionCost].
Sometimes you need to repeat extensive information/instructions. Centralizing this into a single spot means future tweaks are controlled by a single entity. You can further simplify this with nesting of values.
- Defines Referencing Columns
Remember that values are processed based on the defines combined with the current row of your reference file. You can create a hybrid define that can pull from the reference as indicated in the above sample.
Define Value factionImg <img=@[image];.90;0;3>
Obviously you can be a lot more creative than these samples but hopefully you get the idea. The goal of defines is to cut down repetition and centralize your core variable values.
There are also project wide defines for use across all layouts/references. See the manual for details.