Godot: Instance-names can not include '@' signs

Created on 2 Apr 2019  Â·  7Comments  Â·  Source: godotengine/godot

Godot version:
3.1

OS/device including version:
Arch linux

Issue description:
If you make multiple instances of the same nodetype, godot names the first instance after the node type and the other ones are prefixed with an @ and suffixed with an @ and a number. For example, if you create two Nodes of type GraphNode, the first instances name is "GraphNode" and the seconds name is "@GraphNode@288" or something like this.
If you want to rename an instance and it does include an @, the @ gets discarded.

var node = GraphNode.instance()
add_child(node)
node.set_name("@GraphNode@200")
print(node.get_name()) # prints GraphNode200

This is problematic if you want to save and load node data and node-connections.

Steps to reproduce:
Make an GraphEdit, attach a script to it. In the script, create an instance of GraphNode and add it as a child. Set it's name to "@GraphNode@100". After that, print the name of the nodes instance. The name is "GraphNode100" and not "@GraphNode@100"

discussion core

Most helpful comment

Well, just name all your instances you care for in unique way so that on the same level of the tree there is no duplication. This way you will now how to access each instance. I use that to save and restore from/to json.

BUT there is no easy to find documentation on which symbols I can safely use in instance names. The reason I ask about this is sometimes I need annotations for objects to which I add special handling (during import or runtime). For example all names ending in _spawn are spawn points and get attached script. But also I need to specify settings so that to select what in particular to spawn and other things. So I want to have some structure of name with separators. Using some characters would be nice to make that expressive. For example having something like "char_spawn#role=gplayer#team=1#group=spawn#id=10" would be nice as there is no other nice way to produce annotations in 3D software for engine to use.

All 7 comments

Why do you want to set such name though? @ is used by the engine internally to indicate nodes that were instanced without being given an explicit name, i.e. we don't actually care about their name. @ is thus a reserved symbol so that you know that nodes with a @ have all been created this way at runtime.

Well, just name all your instances you care for in unique way so that on the same level of the tree there is no duplication. This way you will now how to access each instance. I use that to save and restore from/to json.

BUT there is no easy to find documentation on which symbols I can safely use in instance names. The reason I ask about this is sometimes I need annotations for objects to which I add special handling (during import or runtime). For example all names ending in _spawn are spawn points and get attached script. But also I need to specify settings so that to select what in particular to spawn and other things. So I want to have some structure of name with separators. Using some characters would be nice to make that expressive. For example having something like "char_spawn#role=gplayer#team=1#group=spawn#id=10" would be nice as there is no other nice way to produce annotations in 3D software for engine to use.

Ran into this particular issue when writing a save system, took a while to understand what was happening too. The @ gets serialized just fine, but breaks things down the line when you try to use the name or node path for something (like parenting other nodes) as the @ gets silently stripped, leaving you none the wiser. I guess the proper workflow is to explicitly name all the instanced nodes that get used this way, but would've still been nice to know...

hi, anyone try to save the connections between GrpahNode to Json? i try a lot, still can't done, can any one help? (i can save the GraphNode size, position, and etc, but can't save the connections), thanks!

@xukongwen Please ask support questions on one of the other community channels, not here.

BUT there is no easy to find documentation on which symbols I can safely use in instance names.

Ideally we would use something like XID_Continue (see this and click category search), not sure what Godot currently does (personally I've only ever used English letters and numbers for node names).

Also @ can be in imported files. There should be some name filter functions
in API to create safe names.

On Thu, Sep 24, 2020 at 9:36 AM Aaron Franke notifications@github.com
wrote:

BUT there is no easy to find documentation on which symbols I can safely
use in instance names.

Ideally we would use something like XID_Continue (see this
https://unicode-lookup.netlify.app/ and click category search), not
sure what Godot currently does (personally I've only ever used English
letters and numbers for node names).

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/godotengine/godot/issues/27608#issuecomment-698145261,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAABPU37OORMAWARUQ6ZHATSHLSFVANCNFSM4HDCTTCA
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mefihl picture mefihl  Â·  3Comments

n-pigeon picture n-pigeon  Â·  3Comments

blurymind picture blurymind  Â·  3Comments

SleepProgger picture SleepProgger  Â·  3Comments

Zylann picture Zylann  Â·  3Comments