Pretty print node name

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Bruno Ely

Is there a built-in way of accessing the function that pretty prints variable and node names so a node whose name is OtherworldDoor, for example, could be shown in the UI as “Otherworld Door”?

I’m assuming the functionality is there since the editor automatically generates such names from exported variables, like export(bool) var is_alive being displayed as “Is Alive” in the editor.

This would be useful. I hope someone knows

andersmmg | 2019-06-17 18:17

:bust_in_silhouette: Reply From: Dlean Jeans

Found it! It’s capitalize():

print('OtherworldDoor'.capitalize())

Click here to run the code above.

I didn’t know there’s an online GDScript playground. Cool!

Thomas Karcher | 2019-06-18 12:57

Thanks for showing me the playground, and the function!

andersmmg | 2019-06-18 17:43

Awesome! Thanks for finding that, and for the playground link–that’s incredibly useful

Bruno Ely | 2019-06-19 19:48