You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
GDScript: Support % in shorthand for get_node
The `%` is used in scene unique nodes. Now `%` can also be used instead of `$` for the shorthand, besides being allowed generally anywhere in the path as the prefix for a node name.
This commit is contained in:
@@ -667,20 +667,8 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
|
||||
case GDScriptParser::Node::GET_NODE: {
|
||||
const GDScriptParser::GetNodeNode *get_node = static_cast<const GDScriptParser::GetNodeNode *>(p_expression);
|
||||
|
||||
String node_name;
|
||||
if (get_node->string != nullptr) {
|
||||
node_name += String(get_node->string->value);
|
||||
} else {
|
||||
for (int i = 0; i < get_node->chain.size(); i++) {
|
||||
if (i > 0) {
|
||||
node_name += "/";
|
||||
}
|
||||
node_name += get_node->chain[i]->name;
|
||||
}
|
||||
}
|
||||
|
||||
Vector<GDScriptCodeGenerator::Address> args;
|
||||
args.push_back(codegen.add_constant(NodePath(node_name)));
|
||||
args.push_back(codegen.add_constant(NodePath(get_node->full_path)));
|
||||
|
||||
GDScriptCodeGenerator::Address result = codegen.add_temporary(_gdtype_from_datatype(get_node->get_datatype()));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user