Extending Format Strings
Format strings can be extended using the API.
Additional functions or overrides of existing functions can be included by calling OmiChat.extension.registerInterpolatorFunction.
If you think your extension should instead be included in the mod, feel free to contribute!
Warning
OmiChat does not perform error handling for interpolation functions. Extensions should adhere to the convention of returning the empty string for invalid inputs rather than causing an error. Return values of
nilorfalsewill also be treated as the empty string.
Example
A simple example which appends the length of the input:
-- $example(hello) → hello5
local OmiChat = require 'OmiChat/Client'
OmiChat.extension.registerInterpolatorFunction('example', function(_interpolator, str)
if not str then
return
end
return str .. #str
end)