libtcoddocumentation

10.4. Standard types

The parser can parse natively several data types. It stores them in a generic union :

typedef struct {
    int
nb_rolls;
    int
nb_faces;
    float
multiplier;
    float
addsub;
}
TCOD_dice_t;
    typedef
union {
    bool
b;
    char
c;
    int32
i;
    float
f;
    char
*s;
    TCOD_color_t
col;
    TCOD_dice_t
dice;
    TCOD_list_t
list;
    void
*custom;
}
TCOD_value_t;

Possible types are defined by the TCOD_value_type_t enumeration :
For python, remove TCOD_ : libtcod.TYPE_BOOL

TCOD_value_type_tValue in fileTCOD_value_t
TCOD_TYPE_BOOLtrue
false
value.b == true/false
TCOD_TYPE_CHARdecimal notation : 0 .. 255
hexadecimal notation : 0x00 .. 0xff
char notation : 'a' ';' ...
Special characters :
'\n' : carriage return (ascii 13)
'\t' : tabulation (ascii 9)
'\r' : line feed (ascii 10)
'\\' : antislash (ascii 92)
'\"' : double-quote (ascii 34)
'\'' : simple quote (ascii 39)
'\xHH' : hexadecimal value, same as 0xHH, HH between 0 and FF
'\NNN' : octal value, NNN between 0 and 377
value.c == The corresponding ascii code
TCOD_TYPE_INTdecimal notation : -2147483648 .. 2147483647
hexadecimal notation : 0x0 .. 0xFFFFFFFF
value.i == the integer value
TCOD_TYPE_FLOATAny format parsable by atof. Examples:
3.14159
1.25E-3
value.f == the float value
TCOD_TYPE_STRINGA double-quote delimited string :
"This is a string"
Support the same special characters as TCOD_TYPE_CHAR.
value.s == the corresponding string.
Warning ! If you want to store this string, you have to duplicate it (with strdup) as it will be overwritten by the parser
TCOD_TYPE_COLORdecimal notation : "16,32,64"
hexadecimal notation : "#102040"
value.col == the color.
TCOD_TYPE_DICE[multiplier (x|*)] nb_rolls (d|D) nb_faces [(+|-) addsub] :
"3d6"
"3D6+2"
"0.5x3d6-2"
"2*3d8"
value.dice == the dice components
TCOD_TYPE_VALUELISTxxSame as TCOD_TYPE_STRINGvalue.s == the string value from the value list
TCOD_TYPE_LIST[ <value1>,<value2>,... ]value.list == the TCOD_list_t containing the elements


To define a list type, use the appropriate function (TCODParserStruct::addListProperty / TCOD_parser_add_list_property) and specify the type of the elements in the list. Lists of list are not supported.