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

Make Node.get_node() pause editor execution if it can't find the node #1729

Open
ShalokShalom opened this issue Oct 26, 2020 · 4 comments
Open

Comments

@ShalokShalom
Copy link

ShalokShalom commented Oct 26, 2020

Describe the project you are working on:

Applies to all projects, GDScript.

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

Get_node can get the current node on an empty NodePath
Lots of bugs and confusion behavior occurs because of that.

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

Yield an error, instead of accepting confusing behavior

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

Already implemented: https://monnef.gitlab.io/golden-gadget

Screenshot_2020-10-26-09-26-03-66

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

No

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

This is similar to the nil issue and solved in some way that is always beneficial and never technically disadvantageous.

@Calinou
Copy link
Member

Calinou commented Oct 26, 2020

I think we should just make get_node() pause the editor execution if the node can't be found (like GDScript errors do), but this isn't currently feasible.
Edit: It's feasible, see godotengine/godot#50955.

If you're not sure whether the node exists, use get_node_or_null() instead which fails silently if it can't find the node.

@Calinou Calinou changed the title Get Node save Make get_node() pause editor execution if it can't find the node Oct 26, 2020
@Calinou Calinou changed the title Make get_node() pause editor execution if it can't find the node Make Node.get_node() pause editor execution if it can't find the node Oct 26, 2020
@Calinou
Copy link
Member

Calinou commented Jul 27, 2021

When reading this proposal a second time, I realized it's about something different entirely. According to OP, get_node("") or $"" returns the current node, but I think it should result in an error similar to using a nonexistent node path. If you want to get the current node for some reason, you should use get_node(".") or $"." instead.

Either way, this should be addressed in a different pull request.

@ShalokShalom
Copy link
Author

So I close this?

@Calinou
Copy link
Member

Calinou commented Jul 28, 2021

@ShalokShalom I'll keep it open, as I think this proposal is still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants