Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_node_and_resource docs are confusing #2975

Closed
rcorre opened this issue Dec 10, 2019 · 1 comment · Fixed by godotengine/godot#68560
Closed

get_node_and_resource docs are confusing #2975

rcorre opened this issue Dec 10, 2019 · 1 comment · Fixed by godotengine/godot#68560
Labels
area:class reference Issues and PRs about the class reference, which should be addressed on the Godot engine repository enhancement

Comments

@rcorre
Copy link
Contributor

rcorre commented Dec 10, 2019

The docs for Node.get_node_and_resource seem contradictory:

If several nested resources are specified in the NodePath, the last one will be fetched.

To me, that says that get_node_and_resource("Area2D/CollisionShape2D:shape:extents") will fetch extents, because that is the "last" of several "nested" resources. However, the docs instead show this:

print(get_node_and_resource("Area2D/CollisionShape2D:shape:extents")) # [[CollisionShape2D:1161], [RectangleShape2D:1156], :extents]

So it seems the first resource is fetched, and the remaining resources are just returned as an "extra" nodepath.

@akien-mga
Copy link
Member

It's confusing but it was hard to document this weird method, which has a confusing behaviour :)

It does give you the last resource, which is shape. extents is a Vector2 property, not a Resource. There are some resources which have subresources as properties, in which case the method actually gives you the last Resource specified.

@NathanLovato NathanLovato added the area:class reference Issues and PRs about the class reference, which should be addressed on the Godot engine repository label Sep 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:class reference Issues and PRs about the class reference, which should be addressed on the Godot engine repository enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants