string_util¶
Source: base/tealdef/scripts/string_util.d.tl
Notes
Types of /scripts/string_util.tl (StringUtil): {placeholder} string interpolation and
prefix/suffix tests. The functions come from the legacy /scripts/stringutil.lua.
StringUtil¶
record global base/tealdef/scripts/string_util.d.tl:3
global record StringUtil
Load: local string_util = ug_require "/scripts/string_util.tl"
Notes
String helpers returned by ug_require "/scripts/string_util.tl".
Functions
format(string) : string base/tealdef/scripts/string_util.d.tl:4
Call as string_util.format
Notes
Replaces {name} placeholders in a string with values from a table (the legacy string.interp).
Returns string
Details
- With a table,
{name}is replaced bytab.name(ortab[number]for{1},{2}, ...); unknown placeholders stay as they are. - An empty
{}is numbered automatically: the first{}becomes{1}, the next{2}, and so on. - With string arguments instead of a table (
format(s, a, b, ...)), the{}placeholders are filled witha,b, ... in order.
Example
Used in the base game: 26 times in 9 files
base/content/mission/mission/mission_react_util.tl:486
log.error(string_util.format("enqueueUnlessExisting for taskUid = {}, instructionKey = {} did not generate any InstructionData", taskUid, instructionKey))
base/content/gui/gui/node_editor/layer_nodes.script.tl:292
local txt = string_util.format("Attempting to spawn {numRivers} rivers with {numAttempts} sample locations, spawned {numActual} rivers (of which {numInnerRivers
base/content/gui/gui/menu/new_game_react_util.tl:39
base/content/gui/gui/main/react.lua:70
log.warning(string_util.format("RegisterExtensionPoint failed because the name is already used: {name}", {name = fullyQualifiedName}))
base/content/gui/gui/entity_window/town/town.tl:246
tooltip = app_util.isGamepadInputMode() and string_util.format(_("Received: {count}"), { count = text }) or nil,
base/content/gui/gui/entity_window/industry/industry_eow.script.tl:247
… and 3 more files.
format(string, {string : string}) : string base/tealdef/scripts/string_util.d.tl:5
Call as string_util.format
Notes
Replaces {name} placeholders in a string with values from a table (the legacy string.interp).
Returns string
Details
- With a table,
{name}is replaced bytab.name(ortab[number]for{1},{2}, ...); unknown placeholders stay as they are. - An empty
{}is numbered automatically: the first{}becomes{1}, the next{2}, and so on. - With string arguments instead of a table (
format(s, a, b, ...)), the{}placeholders are filled witha,b, ... in order.
Example
Used in the base game: 26 times in 9 files
base/content/mission/mission/mission_react_util.tl:486
log.error(string_util.format("enqueueUnlessExisting for taskUid = {}, instructionKey = {} did not generate any InstructionData", taskUid, instructionKey))
base/content/gui/gui/node_editor/layer_nodes.script.tl:292
local txt = string_util.format("Attempting to spawn {numRivers} rivers with {numAttempts} sample locations, spawned {numActual} rivers (of which {numInnerRivers
base/content/gui/gui/menu/new_game_react_util.tl:39
base/content/gui/gui/main/react.lua:70
log.warning(string_util.format("RegisterExtensionPoint failed because the name is already used: {name}", {name = fullyQualifiedName}))
base/content/gui/gui/entity_window/town/town.tl:246
tooltip = app_util.isGamepadInputMode() and string_util.format(_("Received: {count}"), { count = text }) or nil,
base/content/gui/gui/entity_window/industry/industry_eow.script.tl:247
… and 3 more files.
format(string, {string : string}) : string base/tealdef/scripts/string_util.d.tl:6
Call as string_util.format
Notes
Replaces {name} placeholders in a string with values from a table (the legacy string.interp).
Returns string
Details
- With a table,
{name}is replaced bytab.name(ortab[number]for{1},{2}, ...); unknown placeholders stay as they are. - An empty
{}is numbered automatically: the first{}becomes{1}, the next{2}, and so on. - With string arguments instead of a table (
format(s, a, b, ...)), the{}placeholders are filled witha,b, ... in order.
Example
Used in the base game: 26 times in 9 files
base/content/mission/mission/mission_react_util.tl:486
log.error(string_util.format("enqueueUnlessExisting for taskUid = {}, instructionKey = {} did not generate any InstructionData", taskUid, instructionKey))
base/content/gui/gui/node_editor/layer_nodes.script.tl:292
local txt = string_util.format("Attempting to spawn {numRivers} rivers with {numAttempts} sample locations, spawned {numActual} rivers (of which {numInnerRivers
base/content/gui/gui/menu/new_game_react_util.tl:39
base/content/gui/gui/main/react.lua:70
log.warning(string_util.format("RegisterExtensionPoint failed because the name is already used: {name}", {name = fullyQualifiedName}))
base/content/gui/gui/entity_window/town/town.tl:246
tooltip = app_util.isGamepadInputMode() and string_util.format(_("Received: {count}"), { count = text }) or nil,
base/content/gui/gui/entity_window/industry/industry_eow.script.tl:247
… and 3 more files.
format(string, string, ...: any) : string base/tealdef/scripts/string_util.d.tl:7
Call as string_util.format
Notes
Replaces {name} placeholders in a string with values from a table (the legacy string.interp).
Returns string
Details
- With a table,
{name}is replaced bytab.name(ortab[number]for{1},{2}, ...); unknown placeholders stay as they are. - An empty
{}is numbered automatically: the first{}becomes{1}, the next{2}, and so on. - With string arguments instead of a table (
format(s, a, b, ...)), the{}placeholders are filled witha,b, ... in order.
Example
Used in the base game: 26 times in 9 files
base/content/mission/mission/mission_react_util.tl:486
log.error(string_util.format("enqueueUnlessExisting for taskUid = {}, instructionKey = {} did not generate any InstructionData", taskUid, instructionKey))
base/content/gui/gui/node_editor/layer_nodes.script.tl:292
local txt = string_util.format("Attempting to spawn {numRivers} rivers with {numAttempts} sample locations, spawned {numActual} rivers (of which {numInnerRivers
base/content/gui/gui/menu/new_game_react_util.tl:39
base/content/gui/gui/main/react.lua:70
log.warning(string_util.format("RegisterExtensionPoint failed because the name is already used: {name}", {name = fullyQualifiedName}))
base/content/gui/gui/entity_window/town/town.tl:246
tooltip = app_util.isGamepadInputMode() and string_util.format(_("Received: {count}"), { count = text }) or nil,
base/content/gui/gui/entity_window/industry/industry_eow.script.tl:247
… and 3 more files.
starts(string, string) : boolean base/tealdef/scripts/string_util.d.tl:9
Call as string_util.starts
Notes
True if the first string begins with the second.
Returns boolean
Used in the base game: 21 times in 9 files
base/content/mission/mission/mission_sim.script.tl:756
elseif type(v.genericState.optionDecision) == "string" and string_util.starts(v.genericState.optionDecision as string, "finish") then
base/content/mission/mission/mission_task_util.tl:240
base/content/mission/mission/tasks/utility/check_entities.tl:6
base/content/gui/gui/main/content_card.tl:73
base/content/gui/gui/entity_window/make_non_entity_window.tl:20
base/content/game_mechanics/game_mechanics/company/company_static_util.tl:49
… and 3 more files.
ends(string, string) : boolean base/tealdef/scripts/string_util.d.tl:10
Call as string_util.ends
Notes
True if the first string ends with the second (always true for an empty suffix).
Returns boolean