23 lines
598 B
GDScript
23 lines
598 B
GDScript
class_name DialogText extends Resource
|
|
|
|
#contains the raw text info, allows you to iterate through it line-by-line
|
|
#only parse text once
|
|
|
|
@export_multiline() var text: String
|
|
var _content: Array = []
|
|
|
|
func get_line_raw(line: int) -> String:
|
|
if _content.size() == 0 and text.length() > 0:
|
|
_parse_text()
|
|
if line >= _content.size():
|
|
return ""
|
|
return _content[line]
|
|
|
|
func get_line_count() -> int:
|
|
if _content.size() == 0 and text.length() > 0:
|
|
_parse_text()
|
|
return _content.size()
|
|
|
|
func _parse_text() -> void:
|
|
_content = Array(text.split("\n")).filter(func(line): return line.length() > 0)
|