1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-02 16:38:41 +00:00

Fix core.wrap_text and make its behaviour consistent with the docs

Code based on initial implementation by @dsohler.
This commit is contained in:
sfan5 2017-09-11 16:25:20 +02:00
parent 17fd5fe935
commit 6fa2f6b4aa
4 changed files with 21 additions and 53 deletions

View file

@ -2158,9 +2158,11 @@ Helper functions
* e.g. `string:split("a,b", ",") == {"a","b"}`
* `string:trim()`
* e.g. `string.trim("\n \t\tfoo bar\t ") == "foo bar"`
* `minetest.wrap_text(str, limit)`: returns a string
* Adds new lines to the string to keep it within the specified character limit
* `minetest.wrap_text(str, limit, [as_table])`: returns a string or table
* Adds newlines to the string to keep it within the specified character limit
Note that returned lines may be longer than the limit since it only splits at word borders.
* limit: Maximal amount of characters in one line
* as_table: optional, if true return table of lines instead of string
* `minetest.pos_to_string({x=X,y=Y,z=Z}, decimal_places))`: returns string `"(X,Y,Z)"`
* Convert position to a printable string
Optional: 'decimal_places' will round the x, y and z of the pos to the given decimal place.