Name of object from variable

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

I would need write name of object with variable…

For example something like this:

var numberofbutton = 8
$"Node2D/Button"+str(numberofbutton).visible = false

Thanks for answer.

:bust_in_silhouette: Reply From: avencherus
get_node(str("Node2D/Button", numberofbutton))

I finally know, I’ve been looking for this for a long time!
Thank you very much!

Eidam | 2020-05-04 18:11

No problem. :slight_smile:

The $ is short-hand for get_node(), and isn’t as flexible. Many of these tree related functions can be found on the Node class:

Node — Godot Engine (stable) documentation in English

avencherus | 2020-05-05 13:19