Godot-proposals: Add a way to have @ in custom node names

Created on 7 May 2020  路  1Comment  路  Source: godotengine/godot-proposals

Describe the project you are working on:

Plugin to help with networking.

Describe the problem or limitation you are having in your project:

When replicating node spawning, I need to replicate the name as well. This is not possible for names that have an @ in them, because they get removed.

Example:

node.name = "@Bullet@2@"
print(node.name)
# prints Bullet2

Describe the feature / enhancement and how it helps to overcome the problem or limitation:

A method to set the name of a node without validating it.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:

A Node::set_node_name_without_validation function or something. Just https://github.com/godotengine/godot/blob/49a1e3db12a5543ab9e512ad04c478d9d5ef77c7/scene/main/node.cpp#L1021-L1042 without _validate_node_name.

If this enhancement will not be used often, can it be worked around with a few lines of script?:

That's exactly the problem, it can't be worked around.

Is there a reason why this should be core and not an add-on in the asset library?:

It's not possible.

core

Most helpful comment

As a workaround I ensure that the node name is free from the @ in the first place when it's added to the SceneTree on the server-side:

# utils.gd
static func normalize_node_name(node):
    node.name = node.name.replace('@', '')
# autoload.gd
func _ready():
    get_tree().connect("node_added", self, "_on_node_added")

func _on_node_added(node):
    Utils.normalize_node_name(node)

>All comments

As a workaround I ensure that the node name is free from the @ in the first place when it's added to the SceneTree on the server-side:

# utils.gd
static func normalize_node_name(node):
    node.name = node.name.replace('@', '')
# autoload.gd
func _ready():
    get_tree().connect("node_added", self, "_on_node_added")

func _on_node_added(node):
    Utils.normalize_node_name(node)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

WilliamTambellini picture WilliamTambellini  路  3Comments

arkology picture arkology  路  3Comments

WizzardMaker picture WizzardMaker  路  3Comments

regakakobigman picture regakakobigman  路  3Comments

aaronfranke picture aaronfranke  路  3Comments