How to precisely control text flow in Label node for dialog?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Paar

Hi everyone! I’m trying to make Label node behave in particular way but so far without success. This is the behavior I want:

  • Show maximum of 4 lines for a text that is longer than that
  • Gradually reveal every letter by “visible_characters” property, but only for the 4 lines
  • When all 4 lines are revealed, show blinking “continue” indicator
  • After a key press show another 4 lines (or less if it’s the end of the text) with “skipped line” property and begin the “visible characters” animation again

However I’m stuck because I have no idea how to get the information about the text box being full (showing 4 lines) so I can show the “continue” indicator. I would be glad for any kind of help.

The best way would be making the system dynamic so I don’t have to format the text manually with every change in the Label node size.


A Label has two methods that are probably helpful here…

get_line_count() - returns the number of text lines in the label
get_visible_line_count() - returns the number of visible lines in the label

Additionally, there are a few other methods that could be helpful in your solution. See the docs here.

jgodfrey | 2022-04-11 15:53

Those two functions are helpful, unfortunately not as much as I would love to.

get_line_count() gives me all lines in the Label.
get_visible_line_count() gives me number of visible lines in the Label, BUT (!) counting even characters that are not yet visible.

That means, when showing one character after another, I have no way of knowing if I show characters from the first four lines or from the others that are out of textbox boundaries.

Paar | 2022-04-11 17:23

{marked as deleted}

Paar | 2022-04-12 10:06

:bust_in_silhouette: Reply From: Paar

I’ve managed to make it work. Had to write my own logic how to split the continuous text into separate segments. First, I’ve split the text into tokens using " " as delimiter and then been puttin word by word into the Label. When the text has overflown the Label (get_line_count() was bigger than the maximum number of lines I wanted to show), I’ve created a segment and start over with the rest of the words. Works nicely.
How much easier would it be if we had somethin like get_visible_characters() method.