0 votes

I know there is the function get_basename() on type String but if I call it on name, I get printed @Test@99. So the node's name of my instanced scene be "Test", how to get it? I want to do that because sometimes another Object with the same script is added.

Godot version 3.2.3.stable
in Engine by (377 points)

2 Answers

0 votes

I had that problem also and I didn't find any option to call name or even custom class name. Filename worked for me, it is unique just like name and means resource path of your scene. It should do if You only need to identify nodes.

by (1,110 points)
0 votes
func node_name():
    return str(name.replace("@", "").replace(str(int(name)), ""))
by (3,066 points)
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 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 webmaster@godotengine.org with your username.