You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-10 13:00:37 +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:
@@ -1,2 +1,2 @@
|
||||
GDTEST_PARSER_ERROR
|
||||
Expect node path as string or identifier after "$".
|
||||
Expected node path as string or identifier after "$".
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
GDTEST_PARSER_ERROR
|
||||
Expect node path as string or identifier after "$".
|
||||
Expected node path as string or identifier after "$".
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
GDTEST_PARSER_ERROR
|
||||
Expect node path as string or identifier after "$".
|
||||
Expected node path as string or identifier after "$".
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
GDTEST_PARSER_ERROR
|
||||
Expect node path after "/".
|
||||
Expected node path as string or identifier after "/".
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
extends Node
|
||||
|
||||
func test():
|
||||
var child = Node.new()
|
||||
child.name = "Child"
|
||||
add_child(child)
|
||||
child.owner = self
|
||||
|
||||
var hey = Node.new()
|
||||
hey.name = "Hey"
|
||||
child.add_child(hey)
|
||||
hey.owner = self
|
||||
hey.unique_name_in_owner = true
|
||||
|
||||
var fake_hey = Node.new()
|
||||
fake_hey.name = "Hey"
|
||||
add_child(fake_hey)
|
||||
fake_hey.owner = self
|
||||
|
||||
var sub_child = Node.new()
|
||||
sub_child.name = "SubChild"
|
||||
hey.add_child(sub_child)
|
||||
sub_child.owner = self
|
||||
|
||||
var howdy = Node.new()
|
||||
howdy.name = "Howdy"
|
||||
sub_child.add_child(howdy)
|
||||
howdy.owner = self
|
||||
howdy.unique_name_in_owner = true
|
||||
|
||||
print(hey == $Child/Hey)
|
||||
print(howdy == $Child/Hey/SubChild/Howdy)
|
||||
|
||||
print(%Hey == hey)
|
||||
print($%Hey == hey)
|
||||
print(%"Hey" == hey)
|
||||
print($"%Hey" == hey)
|
||||
print($%"Hey" == hey)
|
||||
print(%Hey/%Howdy == howdy)
|
||||
print($%Hey/%Howdy == howdy)
|
||||
print($"%Hey/%Howdy" == howdy)
|
||||
print($"%Hey"/"%Howdy" == howdy)
|
||||
print(%"Hey"/"%Howdy" == howdy)
|
||||
print($%"Hey"/"%Howdy" == howdy)
|
||||
print($"%Hey"/%"Howdy" == howdy)
|
||||
print(%"Hey"/%"Howdy" == howdy)
|
||||
print($%"Hey"/%"Howdy" == howdy)
|
||||
print(%"Hey/%Howdy" == howdy)
|
||||
print($%"Hey/%Howdy" == howdy)
|
||||
@@ -0,0 +1,19 @@
|
||||
GDTEST_OK
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
Reference in New Issue
Block a user