Frostdev

KilnAPI reference Guide

Display names

Every Kiln API type that names a game thing a player can see has a name for players: an item, a creature, a buff, a skill node, a quest, an NPC, a station, a place. Since 0.2.0-dev.31.35 it is a string property that is never null and never a debug name as it stands. Show it instead of names like Material_T2_Ore_Copper.

foreach (var slot in Items.Read(player.Entity)!.Slots)
    if (!slot.IsEmpty) Log.Info($"{slot.Count} x {slot.DisplayName}");   // "12 x Copper Ore"
foreach (var buff in Abilities.BuffsOf(player.Entity))
    Log.Info($"{buff.DisplayName} ({buff.DisplayNameSource})");          // "Chill (Game)"

Where a name comes from

Each name is the first of these that has one:

  1. Game: the game's own text. On a game client it is in the game's text language (German on a German client), read from the game's data; DisplayNameIn(language) asks for another language the game ships. A dedicated server's data has no texts (see What a server can name).
  2. Catalog: the English names Kiln ships with itself: its item catalog (4,390 items since 0.2.0-dev.32.8: the game data of Enshrouded Patch #2 plus the items older builds still have; 4,262 before) and its creature catalog.
  3. Mod: the name the mod that added the thing gives it in its definition (displayName, or its texts in the player's language): kiln.content's new items, gamedata perk and buff clones, Kiln quests.
  4. Derived: a readable name made from the debug name by DisplayNames.FromDebugName (below). It is readable, but it is not the game's name: Weapon_T1_1H_Sword_01 is "Sword (T1)", while the game calls it "Rusty Sword".

DisplayNameSource (an enum: Game, Catalog, Mod, Derived) says which one answered, so a mod can tell a real name from a made one. A mod that used to check DisplayName for null or "" ("does the catalog know this?") tests DisplayNameSource != DisplayNameSource.Derived instead, for example to fall back to its own name list:

var name = info.DisplayNameSource == DisplayNameSource.Derived ? myNames.GetValueOrDefault(info.Name, info.DisplayName) : info.DisplayName;

The names are worked out each time they are read, from tables Kiln reads in the background: they never wait. The first read of a game client's texts or of the game's buff and skill lists starts the read and answers with the next source meanwhile (a fraction of a second). Keep a name per frame, not per call, when you draw many.

The item the game shows

Since 0.2.0-dev.32.1 Kiln knows the item the game shows in a slot. A building tool's slot holds the shape or brush last picked with it (the Construction Hammer's slot holds e.g. "Single Terrain Block 0,5m"), and the game names and draws that slot as the tool (client 26430625's item view, docs/re/building.md "In an inventory"). By the item's flags, the first that matches:

Flag Shown as
IsBlueprint (building and terrain shapes, the hammers) Construction Hammer (Tool_Quickbuilder_Hammer)
IsBuildingOvergrowthTool (Overgrowth brushes, the tools) Overgrowth Tool (Tool_Building_Overgrowth)
IsBuildingDecayTool (Decay shapes, the tools) Decay Tool (Tool_Building_Decay)
IsBuildingScrewdriverTool (Sparkworks logic items) Sparkworks Tool (Tool_Building_Screwdriver)
IsNpc (villagers) Summoning Staff (NpcSummoner_Intro)

The improved tools and a mod's clones of a shape are shown as the tool too, as the game shows them.

A copy of a tool is a tool of its own (since 0.2.0-dev.32.9). A kiln.content item copies its base's flags, so the game named a copy of the Construction Hammer "Construction Hammer" in the action bar, the bag and the workbench, whatever its own name. Now, where the game would show a new item as its root base (the game item at the end of its BaseOn chain), it shows the new item itself: on a Kiln client the game's own screens (content.shown_self*, content.md), and Items.ShownAs, ItemInfo.ShownAs and InventorySlot.DisplayName everywhere. A copy of a shape still shows as the tool that picks it, a copy of the improved hammer as the Construction Hammer. A pick still replaces the tool in its slot with the picked shape (the game's building menu does that), and that shape shows as the Construction Hammer.

Two kinds of name. DisplayName names the item itself; for what a player sees in a slot use InventorySlot.DisplayName or InventorySlot.ShownItem.

Names what a player sees in a slot or a hand (the tool) Names the item itself (the shape)
InventorySlot.DisplayName, InventorySlot.ShownItem ItemInfo.DisplayName (and Label), Items.DisplayName(id)
PlayerItem.DisplayName (held, worn, used items) Items.DisplayNameIn, Items.Description
Items.ShownAs(item), ItemInfo.ShownAs (the item, not a name) the items, loot, stations and itemInfo registries' entries
ui.ItemIconAsShown, ui.ItemIconTrimmedAsShown, Ui.ItemImageAsShown ui.ItemIcon, ui.ItemIconTrimmed, Ui.ItemImage

So every shape keeps a name of its own in catalogs, item search, the admin Content page and the launcher's Conflicts rows, while a mod's inventory window shows the hammer as the hammer. The shown item's name by id is Items.DisplayName(Items.ShownAs(item)); its description Items.Description(Items.ShownAs(item)). Give, take and move the item itself (InventorySlot.Item). Icons: ui.md.

The flags come from the world's item registry on the host and from the item's own game data on a client that joined another's world (a kiln.content item's from kiln.content's listing of it), so every player sees the same answer.

Made from the debug name

DisplayNames.FromDebugName(debugName) turns a game debug name into words:

Debug name Derived name
Material_T2_Ore_Copper Copper Ore (T2)
Consumable_Potion_Mana_T5 Mana Potion (T5)
Weapon_T1_1H_Sword_01 Sword (T1)
Armor_T1_Warrior_DPS_Arms Warrior DPS Arms (T1)
Enemy_Vukah_Melee Vukah Melee
Base_Enemy_Fogger_Soldier_hook_AG2 Fogger Soldier
NPC_Workshop_Bard01 Workshop Bard
Perk_Resistance_Ice_T1 Resistance Ice (T1)
Prop_Decoration_T6_Boardwalk_2m_01_A Boardwalk 2m (T6)
buff_1a2b3c4d Buff 1a2b3c4d
VC_Beard02_chincurtain Beard: Chin Curtain
VC_Body_LowerArms_Female_05_elder Lower Arms: Female Elder

The rules:

  • The name is split into parts at _ - . : / and spaces. Parts that mark a designer's variant go: animation graph versions (AG2), hook templates (hook, hookPtE), WIP, OLD, boss health bar copies (BossHealthBar), Gen0, _DEPRECATED_, map sizes (8k), REWARD.
  • The first tier tag T1 to T9 moves to the end in brackets.
  • Leading kind words go, as whole parts, while another part follows: Material, Weapon, Armor, Consumable, Food, Ammo, Prop, Vanity, Craft, Tool, Shield, Blueprint, Build, Block, Enemy, NPC, Base, Wildlife, Wildbeast, Ability, Animal, Perk and the like (WeaponStandWall keeps its "Weapon"; after Perk the next word stays: Perk_Armor_Cut is "Armor Cut").
  • The parts are split inside CamelCase (HammerEpic is "Hammer Epic").
  • Handedness (1H, 2H, 2Hander), level tags (lvl47), designer markers (Loot, CRAFTING) and a trailing variant (_01, _01_a) go.
  • A kind noun the game puts first moves behind its qualifier: Ore_Copper is "Copper Ore", Potion_Mana "Mana Potion", Torch_Wall "Wall Torch".
  • Words are capitalised. Short acronyms (DPS, NPC), roman numerals (III), sizes (4m, 2x2) and hexadecimal ids keep their case.
  • A character's looks (the game's customization items, VC_...: hair, beards, body parts, which have no text of their own) are "Part: Style" (since 0.2.0-dev.32.9): the part is the first word (Beard01 is "Beard", Haircap "Hair Cap"), or for VC_Body_ the body part after it; the rest is the style, variant numbers out and the game's run-together words apart (chincurtain is "Chin Curtain"). With no style left: the part alone, "Body: Chest" for a body part.

Kiln's shipped item list writes the debug name where the game has no text for an item; Kiln reads that as no name (since 0.2.0-dev.32.9; before, such an item's DisplayName was its debug name, Catalog), so the derived name answers (DisplayNameSource.Derived), and Items.DisplayName / Items.DisplayNameIn answer null for it, as for any item Kiln knows no name of. Lookups by the debug name (Items.Lookup, a setting's item) find it as before.

Its unit tests run every name of Kiln's shipped item list; a run over a client catalog's item, perk, recipe, workshop, boss, place and template names and Kiln's creature catalog (9,994 names) gave no empty one.

A GUID comes back as it is, and null or blank gives "". Every DisplayName falls back to an id ("Item 2b0cf1d5", "Entity 0000002a") when there is not even a debug name, so it is never empty; an empty slot is "Empty" and no item "Nothing".

The types

Every type below has DisplayName (a string, never null) and DisplayNameSource.

Behaviour change in 0.2.0-dev.31.35. Eight types already had a DisplayName that was null or "" when Kiln's catalog had no name: ItemInfo, CreatureTemplate, TemplateInfo, GemInfo, StationInfo, ClientStationInfo, StationRecipe and SelectedEntity. Since 0.2.0-dev.31.35 it is the whole chain, never null or empty, like every other DisplayName:

  • Its declared type is the same, so mods built before keep working. A string? one is now marked [NotNull]: code reads it as a string without a warning, and the record's constructor, init and with { DisplayName = ... } still take null. What they take is the name the record is made with (the catalog's), the start of the chain.
  • A check for null or "" no longer finds anything: test DisplayNameSource != DisplayNameSource.Derived to know whether anything names the thing. A mod built before 0.2.0-dev.31.35 that falls back to its own names when the old member is null or "" now gets Kiln's name instead (a derived one when nothing names the thing).
  • ItemInfo.Label stays, as the same name as ItemInfo.DisplayName.
  • Kiln's own lookups by name (Items.Lookup, Items.Search, the creature and template lookups) still match the catalog's names and the debug names only, never a derived one.
  • ToString() of CreatureTemplate and TemplateInfo still shows the catalog's name only.
Type Sources, in order
ItemInfo the game's text of the item's name tag, Kiln's catalog, the mod's name, derived from Name (Label is the same)
InventorySlot, PlayerItem as ItemInfo.DisplayName, of the item the game shows in the slot or hand (since 0.2.0-dev.32.1: The item the game shows); "Empty" for an empty slot, "Nothing" for no item: never empty
StationStack as ItemInfo.DisplayName ("Nothing" for no item: never empty)
CreatureTemplate, TemplateInfo Kiln's catalog, derived from Name
CreatureInfo, EntityInfo, TrackedEntity the template's DisplayName, derived from the template name, the entity id
EntityBuff, PlayerBuff (and DisplayNameIn) the game's text of the buff's name tag, "Buff 1a2b3c4d" (a mod's buff clone has no Mod step here: its GameDataEntry has)
SkillNode (and DisplayNameIn), UnlockedSkillNode, ClientSkillNode, GameNodeInfo the game's text of the node's name tag, derived from GameNodeInfo.Name, "Skill 81d8b64f"
KnowledgeNpc, JournalQuest, Spire, FlameShrine, Boss, Survivor (and DisplayNameIn) the game's text of NameTag, derived from the debug name or id
QuestEntry (and DisplayNameIn) vanilla: as JournalQuest; a Kiln quest: its definition's name (Mod)
SurvivorInfo derived from DebugName (its roster read has no name tag: KnowledgeNpc and Survivor have the game's name)
ContentEntry items and loot: the item's name; recipes: the first result's name, else the recipe's name text; drops: derived
GameDataEntry buffs, perks, skill nodes: the game's text, a clone's mod name; items: the item's name; templates, arsenals, sequences: derived
VoxelMaterial Label (an item's name), derived from Name ("Terrain Stone", "Cell 12")
StationInfo, ClientStationInfo the station item's name or the workshop's text, derived from StationInfo.Template, "Workshop 1a2b3c4d"
StationRecipe the first output's name or the recipe's text, derived from Name
GemInfo a game gem's item name, a mod gem's name, derived from Name
SelectedEntity a player's name, Kiln's catalog, derived from TemplateName
PlacedProp, SchematicProp the name of the item it gives back, its template's DisplayName, derived from the template name
PetSnapshot, PetViewEntry (since 0.2.0-dev.32) a pet is a mod's thing: its definition's Name (Mod), else its creature's name (a game creature's CreatureTemplate.DisplayName: Kiln's catalog, else derived from the template name; a creature block's Name, else derived from its block name), else derived from the definition id (my-mod:hound is "Hound"). Label is the same name. The owner's game gets the server's name and source on kiln:pets
TamingItemChoice, TamingCostView, CostReceipt (since 0.2.0-dev.32) as ItemInfo.DisplayName ("Nothing" for no item); TamingItemChoice.Label leads with it ("Cat Food Bait x4")
SpellCombatPreview (StaffDisplayName, SpellDisplayName), PreviewEffect (since 0.2.0-dev.32.1) the staff, the spell and the gem as ItemInfo.DisplayName; a perk as its GameDataEntry (the game's text, a clone's mod name); the inputs that are not game things (the caster's attributes, talents and effects, the neutral target) are words, always Derived
TamingAttemptView (since 0.2.0-dev.32 final) the target's name on the server when the attempt began (CreatureInfo.DisplayName: Kiln's catalog, else derived from the template name), sent on kiln:taming v2; from a server that sends v1, derived from the target's entity id
Registry entries (since 0.2.0-dev.32 final): every Kiln.Registry entry type, RegistryEntry and IRegistryEntry by the registry's rule, which its page states under Ids ("Names"); the table below. An id the registry's service does not know: derived from the id
RegistryViewEntry, RegistryViewSnapshot (since 0.2.0-dev.32 final) a stable view's entry: its registry entry's name; the template view's (also an entry's Template): the template's; the perk view's: the perk's; another advanced view's: derived from its id
RegistryView (since 0.2.0-dev.32 final) the view's Kiln name as words ("Terrain Materials"), always Derived

Not given one, because they are already names for players or a mod's own text: Player.Name (the character's name), the definition types a mod fills in (ItemDefinition, AbilityDefinition, RecipeDefinition, GemDefinition, GameDataClone: their DisplayName is what the mod gives; dev.32's PetDefinition.Name, TamingDefinition, PetBlock and TamingBlock too), CreatureVariant.Name, TalentTree and TalentNode (UiText names), the authoring blocks (ItemBlock.Name...). Types that only refer to a thing by id (ItemId, KnowledgeInfo, GameplayRecipe; dev.32's ItemSelection, TamingProgress and the native taming events, which name a creature by its entity) are named through the thing: Items.Get(id).DisplayName, Spawn.Inspect(entity)?.DisplayName, or Items.DisplayName(id) (a method of 0.2.0-dev.29.15 that still answers null for an id Kiln knows no name of).

Registry entries and views

Since 0.2.0-dev.32 final every registry entry and view entry has a DisplayName and DisplayNameSource, worked out from its Kiln id (game:enemy_wildbeast_wolf is "Wolf"). The id stays the entry's identity: edits, selectors and searches take it, and a UI shows it only where someone asks for it (a raw-id view, a tooltip). The service that knows the thing answers for its registries; a registry whose service has no name for an id, and a mod's entry the game's lists do not have yet, get a name made from the id: its part after the colon, without a clash suffix (my-mod:stout_logs is "Stout Logs").

Registries (and views) Named by From
items, loot, stations, the itemInfo view Kiln.Items the item's name (ItemInfo.DisplayName), by the world's item list, else the catalog Kiln ships (a game client in another's world); a station without an item: its workshop's text
creatures, impacts, storage, spawns, movement (since 0.2.0-dev.32.1), arsenals, drops, the template view Kiln.Spawn the template's name (TemplateInfo.DisplayName: Kiln's catalog, else derived from the template's debug name); an arsenal or drop table: the template it is named after
recipes, perks, buffs, materials, terrainMaterials, the perk view Kiln.Content a recipe's first result's name, else its text; a perk's or buff's game text, else a clone's mod name; a material's VoxelMaterial.DisplayName. kiln.content's recipe and perk lists are the game thread's: read there once when a name is first asked for, so the very first read of a recipe or perk off the game's thread is made from its id
skills Kiln.Api the game's text of the node's name, else "Skill 4475e8dd"
mapMarkerLooks (since 0.2.0-dev.32.2) Kiln.Markers the game's text of the marker kind's name (most kinds have none), else a name made from its icon's name in the game's data (the icon catalog's alias: well_plant is "Well Plant"), else "Marker 1095684e"; a game client's only (a server has no marker kinds)
balance, world, difficulty, limits, lootRules; since 0.2.0-dev.32.2 fog, mapZoom, intro Kiln.Registry the registry's name as words ("Loot Rules", "Map Zoom"): one entry, no game thing
difficultyUi (since 0.2.0-dev.32.2) Kiln.Registry "Difficulty Sliders": one entry, the world settings menu's sliders (its name as words would read "Difficulty Ui")
abilities, randomLoot, a declared registry, another advanced view - derived from the id (the game has no names for players for them)

A name is asked of its service once per id and kept: the game's text for good, any other name for 10 s (then asked again, so a list the service has not read yet, or a game client's texts that load later, are caught up). A service whose lookup fails gives the name made from the id for that read, and nothing is kept of it. Nothing runs per tick: kiln.content's lists are read by a service-tick handler that removes itself.

Other languages

DisplayNameIn(language) ("de-de", "pt-br"; null or "" for the game's text language) is on the types whose name is a game text. It answers that language's text where the game's texts are here (a game client has the 15 languages the game ships) and the derived name otherwise. Items have Items.DisplayNameIn(item, language), and any loca tag Content.TextIn(tag, language).

What a server can name

A dedicated server's game data has no texts: the game ships them with its client only (world-status, section 12). So on a server:

  • Items: Kiln's shipped English names (4,390 items, Patch #2's included), the mods' names, and derived names for the rest (items of a newer game build).
  • Creatures and templates: Kiln's shipped English names, else derived.
  • Buffs, skill nodes, perks, quests, NPCs, spires, shrines, bosses, recipe and workshop texts: English when the server has a Kiln catalog of the owner's game (kiln catalog build --side client, then copy client.json to the server's kiln/catalog/; texts.md), else derived. The ids and name tags themselves are in the server's data: Kiln reads BuffTypeCollectionResource and SkillTreeResource there too.
  • No other language than English. A server mod that wants a player's language asks that player's client.

A game client (also one that hosts a world) has all of it in the game's text language.

In the admin protocol

KAP answers that name a game thing carry displayName (camelCase) next to their existing name fields: admin-protocol.md, section 8.

Enshrouded is a trademark of Keen Games GmbH. Kiln is unofficial.