Transferring part of the text to another node (Label, RichtextLabel, TextEdit)

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

I want to understand how to transfer the text to another node that did not fit in the first node. For example, there is some big test and I need to split it so that one part goes to one node and the other to another node.

:bust_in_silhouette: Reply From: alexandremassaro

You could do something like this:

 func _ready():
	var big_text = "Lorem ipsum dolor sit amet"
	var arr_str : Array = text_split(big_text, 2)

	while arr_str.size():
		print(arr_str.pop_front())

 func text_split(text : String, size : int):
	var text_array : Array

	while text.length() > size:
		text_array.append(text.substr(0, size - 1))
		text = text.substr(size)
	if text.length():
		text_array.append(text.substr(0))
		text = ""

	return text_array