mirror of
https://github.com/Refactorio/RedMew.git
synced 2024-12-12 10:04:40 +02:00
add docs
This commit is contained in:
parent
b269f1e18c
commit
2e549700ed
@ -3,6 +3,31 @@ local tostring = tostring
|
||||
local setmetatable = setmetatable
|
||||
local getmetatable = getmetatable
|
||||
|
||||
--- Helper class for concatenating LocalisedStrings / strings.
|
||||
-- strings and LocalisedStrings can be combined in any order.
|
||||
-- Multiple calls to add will automatically split the LocalisedStrings into a linked list
|
||||
-- when needed to prevent exceeding 20 parameter limit imposed by Factorio.
|
||||
-- However, if you pass in LocalisedStrings that exceeds 20 parameters then it will fail.
|
||||
--
|
||||
-- @usage
|
||||
-- LocaleBuilder = require 'utils.locale_builder'
|
||||
-- local locale_string = LocaleBuilder
|
||||
-- .add({'common.fail_no_target', 'player_name'})
|
||||
-- :add({'', '- a literal string'})
|
||||
-- :add('- short hand for literal string')
|
||||
-- :add(3):add(true) -- also works if convertable to string
|
||||
--
|
||||
-- Notice use of :add rather than .add for chaining calls.
|
||||
--
|
||||
-- local part1 = {'', 'part', ' ', 'one'}
|
||||
-- local part2 = LocaleBuilder.add('part'):add(' '):add('two')
|
||||
-- local part3 = LocaleBuilder.add('part'):add(' '):add('three')
|
||||
--
|
||||
-- local result = LocaleBuilder.add(part1):add(part2):add(part3)
|
||||
--
|
||||
-- If you store the LocalisedStrings in global, when you fetch from global you need to restore
|
||||
-- the metatable to be able to use :add calls. To do that use
|
||||
-- LocaleBuilder.add(global_stored_locale_string)
|
||||
local Public = {}
|
||||
|
||||
local add
|
||||
|
Loading…
Reference in New Issue
Block a user