Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Chain | |
Old Version | Published before Godot 3 was released. |
Is there a way to achieve sth like this with an autowrapped label, label.get_line(3)?
PS: I have tried get_text() and then split(“/n”)ing it, but that didn’t work.
extends Label
var text = ["test","a car is cool","Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea est Lorem ipsum dolor sit amet."]
var k = 0
var narrating = false
func _ready():
set_text(text[k])
set_process_input(true)
print(get_max_lines_visible())
func _input(event):
if Input.is_action_pressed("ui_accept") and not narrating:
k+=1
if k >= text.size():
k = 0
set_visible_characters(0)
set_text(text[k])
elif Input.is_action_pressed("ui_accept") and narrating:
set_visible_characters(text[k].length())
func _on_Timer_timeout():
if not get_visible_characters() >= text[k].length():
narrating = true
set_visible_characters(get_visible_characters() + 1)
else:
print(get_text().split("\n")[0]) <-- This doesn't ouput the first line, but the hole text
narrating = false
return
Scene structure: