Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Text: Added text and nickname limiting (#1498)
Adds the following two functions to the game: ```lua --- -- Creates a text that is limited to the provided length. Adds a limiting char (e.g. '...') after the -- text if so desired. The limiting char is only added to the string (and also only then considered -- for the length) if the text without the limiting char is too long for the provided width. -- @param string text The text that may be limited in length -- @param number width The maximum width that should be used to limit the text -- @param[default="DefaultBold"] string font The font ID -- @param[opt] string limitChar The limiting character(s) that might be appended to the end -- @param[default=1.0] number scale The UI scale factor -- @return string The length limited text -- @realm client function draw.GetLimitedLengthText(text, width, font, limitChar, scale) ``` ```lua --- -- Creates an elliptic nick for a given length. -- @param number width The maximum width that should be used to limit the nick -- @param[default="DefaultBold"] string font The font ID -- @param[default=1.0] number scale The UI scale factor -- @return string The length limited nick -- @realm client function plymeta:NickElliptic(width, font, scale) ``` These can be used to limit text / nickname to a given maximum length, while also adding a limiting character. **Example:** ```lua print(LocalPlayer():NickElliptic(50, "DefaultBold", 1.0)) >>> "Tim | M..." ``` --------- Co-authored-by: Histalek <16392835+Histalek@users.noreply.github.com>
- Loading branch information