Godot Version
4.3
Question
I know you can do:
@export var new_text: Array[String]
and get an array of strings, but is there a way to get multi-line strings instead? I tried looking it up, but I’m coming up empty. Thanks!
4.3
I know you can do:
@export var new_text: Array[String]
and get an array of strings, but is there a way to get multi-line strings instead? I tried looking it up, but I’m coming up empty. Thanks!
what is this for? because the answer depends on that.
if this is just text, newlines are defined by the newline symbol \n
. you can keep an entire book in a single String
.
do you mean an array of array of string? yes, but you can’t static type it, it has to be an array.
what you CAN do is use a dictionary of array and maybe assign static typed arrays of string, but I don’t know if the devs though of this or if there’s any benefit to it.
also dictionaries in godot don’t have a safe way of adding a new unique key, so you have too keep score of the id for the last added item or use dictionary size.
also dictionaries in godot are weird because they are sorted (thank reduz for this), so you can just get the keys or iterate through it and it will always be in the same order, so as long as the new key added has a unique name, it is practically an array with extra steps.
If you want the editor to display a larger textbox you use @export_multiline
:
@export_multiline var strings: Array[String] = []
Which works with Array[String]
and String
.
I’m smacking my head. I knew about @export_multiline but I didn’t think to try it with this. Thanks for you help! This is exactly what I needed!