The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

Sorry for the title :P, but hard to explain.

Anyways, simple text placeholder conversion:

var format_string = "%s was reluctant to learn %s, but now he enjoys it."
var actual_string = format_string % ["Estragon", "GDScript"]

print(actual_string)
# output: "Estragon was reluctant to learn GDScript, but now he enjoys it."

Is it possible to do something like this

var format_string = "%customname1 was reluctant to learn %customname2, but now he enjoys it."
var actual_string = format_string % { customname1 = "Estragon", customname2 = "GDScript"}

print(actual_string)
# output: "Estragon was reluctant to learn GDScript, but now he enjoys it."

Reason I ask is I'm creating a fairly large dynamic tooltip for player skills. Need to generate damage, cooldown, skill descriptions, etc on the fly. Doing something like this would be a lot easier then just an array. But, I mean an array is fine it will just be harder to track :P so just seeing if something like this was possible, thanks!

in Engine by (314 points)

AFAIK, There is no such easy way.
Here is same issue. https://github.com/godotengine/godot/issues/5493

@volzhs thanks, looks like it might get implemented down the road, maybe? I hope? :D

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.