Skip to Content
Stoatly Docs
Concepts

Slugs

A slug is the short, lowercase identifier for something in Stoatly. It's generated from a name, then becomes a file name in your repository and a key in your code. Your game depends on slugs, so Stoatly treats changing one very differently from changing a name.

Where slugs appear

ThingWhere the slug is used
Object typeThe folder that holds its record files, and its identifier in code
RecordThe file name, and the value you pass when loading it in code
FieldThe key in each record file, and the property name in code

How they're made

Stoatly builds a slug from the name you type, in lowercase with hyphens between words. A record named Iron Sword gets the slug iron-sword. A field's key is created from its label and stays the same if you rename the label later.

Changing a record's slug

You can change a record's slug if you need to, but it has real effects. The record's file is renamed in your repository, and every call in your game that loads the record by its old slug stops finding it. The old slug doesn't keep working. Stoatly asks you to confirm before it makes the change.

I changed the name of a record, why didn't the slug update?

Slugs act as unique identifiers any time a Record is referenced. Stoatly uses these when Records need to reference other Records, such as a "Lost Treasure" quest's reward field containing a reference to the "Iron Sword" weapon. Changing Iron Sword to Steel Sword shouldn't break that link. This goes beyond Stoatly too, your user's save file for the game would likely contain 'iron-sword'. This would tell the game to load the data referenced by 'iron-sword' when the player opens their inventory. If that changed, the game wouldn't know what 'iron-sword' refers to when there's no data called that, and the player would lose their item.

Duplicate slugs

Two records of the same type can't share a slug. If you duplicate a record, Stoatly renames the copy to keep its slug unique. If you type a name that another record already uses, Stoatly asks you to rename it.

On this page