X3:Terran Conflict ReadMe : Chem String Functions Library (lib.chem.strings)

Title:Chem String Functions Library (lib.chem.strings)
Author:ChemODun aka Chem [EG] [ru]
E-Mail:chemodun@gmail.com
Web:http://www.elite-games.ru/x3tc/
Version:2.97
Description:Provide some functions for manipulate with string, based on their displayed width

installation:

Install via Cycrow Script Manager (Plugin Manager)

usage:

Libraries has one script file:
lib.chem.strings.xml - main library script.
Script has 6 parameters:
mode (Work Mode) - for defining which function called from library
Arg1..Arg5 - for setting functions parameters
1.'split.string.by.delim'
Arg1 - string-delimeter - string, or string from text file by page id Arg1 and text id Arg2
Arg2 - string-source - string, or string from text file by page id Arg2(or Arg3) and text id Arg3 (or $Arg4)
Arg3 (or Arg4, or Arg5) - max count patrs of source string
return - array of found parts of source string
It's function can split source string (first) by separator (second).
You can set maximum count of parts for splitting (Arg3), i.e. if Arg1 has more then one occurrence of delimiter (Arg1), but you set Arg3 = 2 - function will return array with only 2 elements, first - source string before first occurrence of Arg1 in Arg2, and second - all source after this first occurrence.

2.'fill.spaces'
Arg1 - string, or string from text file by page id Arg1 and text id Arg2
Arg2 (or Arg3) - max len in pseudosymbols
Arg3 (or Arg4) -
if bool
TRUE - fill left (align right)
FALSE - fill right (align left)
if string
'-' - align left
'=' - align center
'+' - align right

It's function will fill source string by spaces based not on count of symbols in string, but on their summary width on screen in player logbook.
I.e. default length for one symbols it this function will taken equal to two spaces.
Max screen width = 100 pseudosymbols (200 spaces)
In fact some symbols have length more then two spaces, some - less.
Function use special array, was prepared in setup script by experimental data form text files x8910.xml.
Now supported only English, Russian, and German languages.
If length source string more then (Arg2*2) spaces - string will be truncated.
See examples:
If you browser support animated gif -
http://img72.imageshack.us/img72/5404/lsccompare01engid5.gif
http://img216.imageshack.us/img216/5885/lsccompare02engls6.gif
Or if not:
output without 'fill.spaces'
http://img137.imageshack.us/img137/2357/lcsengnot01rx8.jpg (LCS-Eng-Not-01.jpg )
http://img141.imageshack.us/my.php?image=lcsengnot02vz9.jpg (LCS-Eng-Not-02.jpg )
output wtih 'fill.spaces'
http://img144.imageshack.us/img144/9210/lcsengyes01bc7.jpg (LCS-Eng-Yes-01.jpg )
http://img149.imageshack.us/img149/5686/lcsengyes02xt5.jpg (LCS-Eng-Yes-02.jpg )

3,4 'sum.to.string' and 'number.to.string'
Arg1 - integer
return - string
will do convert number 1234567890 to string like 1,234,567,890 or
will do convert sum 1234567890 to string like 1,234,567,890 Cr (add default name of games currency)

5,6 'fill.sum.to.string'and 'fill.number.to.string'
Arg1 - integer
Arg2 - max length in pseudo symbols
Arg3 - TRUE - fill left (align right) or FALSE - fill right (align left)
return - string
will do convert number 1234567890 to string like 1,234,567,890 or
will do convert sum 1234567890 to string like 1,234,567,890 Cr (add default name of games currency)
Then fill converted string as it can be done via 'fill.spaces'

7 'sprintf'
Arg1 -
if string
- then format string
else if number
- page id for format string
Arg2
if Arg1 = page id
- then text id for format string
else if
- array - then array of params
else
- params
Arg3..Arg5 - params or array of params like Arg2

if param is string and has form (page;id) then it will be replaced with string from text file

Function works like sprintf function from ScE, but use unlimited count of params and extended syntax:

%[align][width]specifier
align:
'-' - left
'=' - center
'+' - right (default)
width:
needed width of string in pseudo symbols
specifier:
'n' - number
'c' - currency
's' - string

8 'length'
Arg1 - string, or string from text file by page id Arg1 and text id Arg2
Arg2 (or Arg3) - type of measurement units.
if [TRUE] - then result will be returned in spaces
otherwise - in pseudosymbols.
This function will return displayed length of source string.

change log:

2.97 - converted to X3:TC

© Chem

Plain text version!