22 lines
590 B
GDScript
22 lines
590 B
GDScript
class_name DialogText extends Resource
|
|
|
|
##Contains raw text for dialog boxes, and allows you to iterate through it line-by-line.
|
|
|
|
@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)
|