Putting a variable within a @export_multiline

Godot Version

4.2.1

Question

I am simply wondering if is it possible to put a variable into a @export_multiline like you would with a text label, like so:

var num_cats = 5
var cat_counter.text = "There a total of " + str(num_cats) + " cats."

If this is possible, I would love to know how. If not, that’s ok too, I am just curious.

dot notation doesn’t work for making new variables, but you can create variables with an expression. I think you will do better with formatted strings though.

@export_multiline var text_input: String = "There are a total of %d cats." % num_cats

Keep in mind this won’t update as num_cats updates, it’s set once and stays that way regardless of other variables used to create the string.

1 Like

I didn’t think about that, I think I got it now then, thanks!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.