Skip to content

Config ID

Config ID is the unique identifier for each config entry. In a regular table it is the first column, while in a tree-backed regular table it is the root map key.

Category Types
String string
Signed integers int, int8, int16, int32, int64
Unsigned integers uint, uint8, uint16, uint32, uint64

The default type is int64 for a regular table, and int for a tree-backed regular table.

In a regular table, place a $%[=type] marker in any cell of the first row:

$% → type: string
$%=string → type: string
$%=int8 → type: int8
$%=int32 → type: int32
$%=uint64 → type: uint64

In a tree-backed regular table, declare the root map as map[K], where the key type K is the config ID type.

$%=string
DescHero nameHero level
Namenamelevel
Typestringint32
hero1Arthur10
hero2Merlin15

The config ID serves as the lookup key when referencing a config entry via the ref type. Similarly, backref and backref-n resolve back-references using config IDs under the hood.

Adding an anchor field to a regular table with integer config IDs bridges the gap between opaque numbers and meaningful names, making ref fields much easier to fill and read. For example, provided the config ID 101 has an anchor value of sword, you can enter sword in a ref cell instead of 101.

DescWeapon name-
Namenameanchor
Typestringanchor
101Swordsword
102Shieldshield

In the generated code, a config ID is not a plain int64 or string. Each regular table has its own ID type, and that type carries a shortcut straight to the config entry it identifies — so you can go from an ID to its entry without holding onto the table and looking it up by hand.

The HeroCfgID type has a Cfg() method. It returns the matching *HeroCfg through the global GetConfigAtlas().

type HeroCfgID int64
func (x HeroCfgID) Cfg() *HeroCfg {
return GetConfigAtlas().HeroTable[x]
}
type HeroCfg struct {
Name string
// ... other fields
}
var cfgID HeroCfgID = 1
name := cfgID.Cfg().Name // <-- one hop from ID to config entry