Skip to content

Return of Reckoning

Wiki

RoR Wiki

API:GetStringFormatFromTable

From RoR Wiki

UI Lua API · Interface functions
Version: WAR 1.4.8

Returns a localised string from a string table with parameters filled in.

text = GetStringFormatFromTable(tableName, id, params)

Arguments

tableName
string – Name of the string table.
id
number – Index of the string in the table.
params
wstring-table – Array of wide strings to substitute into the string's placeholders, in order.

Returns

text
wstring – The string with the parameters substituted.

Details

  • The table name is matched without regard to case.
  • Every entry of params must be a wide string. The stock helper in easystem_strings/source/stringutils.lua converts each entry with WideStringFromData before calling.
  • If id is outside the table, the result is built from an empty string, so L"" is returned. No message is logged.
  • If the table does not exist, error messages are logged and no string is produced. The stock helper guards against this with or L"".

Errors

  • StringTable %s does not exist.
  • Error in function call 'GetStringFormatFromTable': String Table %s does not exist.
  • Error in function call 'GetStringFormatFromTable': Id %d is invalid for table %s.
    This message exists in the client but never appears: the string lookup it depends on always reports success.

Example

From easystem_strings/source/stringutils.lua:

return GetStringFormatFromTable( "Default", StringTables.Default.LABEL_LIST_FORMAT, { currentListText, newItemText } )

From the same file:

-- Convert all params to wstrings
for index, parameter in ipairs (paramTable)
do
    paramTable[index] = WideStringFromData (parameter)
end

text = GetStringFormatFromTable( tableName, id, paramTable ) or L""

See also