• Godot HelpGUI
  • How do I check for a full Label when text is scrolling?

Long story short: I want to achieve this kind of textbox.

So: the text should scroll (= adding letters one by one) until it reaches the limit of the textbox, then waits for player input. After which, all of the text moves up one line, printing a new line, repeating this for 3 new lines until the box awaits player input again. All of this repeats again until all the text is gone.

Right now I'm trying to replicate this by using a normal label ("txt") with Autowrap and Clip Text set to true. I also have rudimentary code:

func scrollText(delta):
    	tween.interpolate_property(txt, "percent_visible", 0, 1, len(txt.text) * scrollSpd, tween.TRANS_LINEAR, tween.EASE_IN_OUT)
    	tween.start()

So text scrolling works, but is there a way to check how many lines are visible according to visible text and making it stop? Or is there at least some way to get Godot to return when it needs to break a line? Godot obviously knows WHEN to do it but how do I access that? Or is there generally a better approach?

I checked out functions like get_line_count(), but that unfortunately seems to count all the lines regardless of whether the text is visible or not. Anything else I can use? I'm on Godot 3.5 btw!

Thanks in advance!!

  • I think richtextlabel should offer more options for this. And the parent box would be a container node such as margin container perhaps. Each paragraph would get it's own rich text label spawned and populated via code(script on the parent container?) and you could spawn in there also buttons and menus in addition to the text labels.

    edit: scratch the margin container, scroll container is probably what you are after.

I think richtextlabel should offer more options for this. And the parent box would be a container node such as margin container perhaps. Each paragraph would get it's own rich text label spawned and populated via code(script on the parent container?) and you could spawn in there also buttons and menus in addition to the text labels.

edit: scratch the margin container, scroll container is probably what you are after.

    6 days later

    Megalomaniak Sorry for the late response and thank you for yours! I think I might give this a try. Right now I basically stuck with the normal Label, have each character added one by one, then check the number of currently visible lines. If it reaches 4, the function goes back one character, sticks to 3, waits for input, then deletes the first line while adding another 3 lines. It's a bit messy so honestly, I might come back to your solutions. Again, thanks!!