Dlcsupport Strings
Based on game build 714014 | Last updated: 2026-03-10
Overview
dlcsupport_strings.lua is a utility module that centralizes the logic for determining whether a given adjective (e.g., wet, smoldering) should be prefixed or suffixed to an entity’s base name when generating localized display names. It provides functions to configure and query this behavior per string key, and to construct the final formatted name. This module supports dynamic language customization, especially for modded content where naming conventions may vary.
Usage example
-- Configure that "smoldering" uses a prefix (e.g., "Smoldering Torch")
SetUsesPrefix(STRINGS.SMOLDERINGITEM, true)
-- Build a formatted name for an entity
local formatted = ConstructAdjectivedName(inst, STRINGS.NAMES.SMOKEY_TORCH, STRINGS.SMOLDERINGITEM)
-- Returns "Smoldering Smokey Torch" if prefix logic applies
Dependencies & tags
Components used: None
Tags: None identified
Properties
No public properties
Main functions
MakeAllSuffixes(fn)
- Description: Sets all entries in
USE_PREFIXto suffix mode (i.e., forces adjectives to appear after the noun), unless a custom functionfnis provided (in which case it overrides the default behavior per key). - Parameters:
fn(function ornil) — optional callback function that receives(inst, name, adjective)and returns a string, orfalseto use suffix format unconditionally. If not a function, treated asfalse. - Returns: Nothing.
- Error states: If
fnis not a function, defaults to suffix behavior (false).
MakeAllPrefixes(fn)
- Description: Sets all entries in
USE_PREFIXto prefix mode (i.e., forces adjectives to appear before the noun), unless a custom functionfnis provided. - Parameters:
fn(function ornil) — optional callback function that receives(inst, name, adjective)and returns a string, ortrueto use prefix format unconditionally. If not a function, treated astrue. - Returns: Nothing.
- Error states: If
fnis not a function, defaults to prefix behavior (true).
SetUsesPrefix(item, usePrefix)
- Description: Explicitly configures whether a given string key (e.g.,
STRINGS.SMOLDERINGITEM) should use a prefix (true) or suffix (false). Also invokesTryGuaranteeCoverageto cross-link related keys for consistency. - Parameters:
item(string) — a string key (e.g.,STRINGS.WET_PREFIX.FOOD).usePrefix(boolean ornil) —truefor prefix,falsefor suffix. Must be non-nil.
- Returns: Nothing.
- Error states: No effect if
itemis not a string orusePrefixisnil.
ConstructAdjectivedName(inst, name, adjective)
- Description: Constructs a formatted display name by combining
nameandadjectiveaccording to configured prefix/suffix rules, optionally delegating to a custom function if defined. - Parameters:
inst(optional table) — the entity instance; used to resolvenameif not provided explicitly.name(optional string) — base display name. Ifnil, derived frominst.prefabviaSTRINGS.NAMES[UPPER(inst.prefab)].adjective(string) — adjective string key or literal (e.g.,STRINGS.WET_PREFIX.FOOD).
- Returns:
string— the formatted name, e.g.,"Wet Food"or"Food Wet"depending on rules. - Error states:
- Returns
name.." "..adjectiveif nousePrefixrule is found for eitheradjectiveorname. - If the configured rule is a function and it returns a non-string value, falls back to default rule (
prefix/suffixbased on boolean).
- Returns
UsesPrefix(item)
- Description: Internal helper to check whether
itemshould use a prefix. Used byConstructAdjectivedName. - Parameters:
item(string) — string key (e.g.,STRINGS.SMOLDERINGITEM). - Returns:
booleanornil—truefor prefix,falsefor suffix, ornilif undefined. - Error states: Returns
nilifitemis not a string or not present inUSE_PREFIX.
Events & listeners
None identified