Consolidate $
into a stronger compile-time only get_node
, rather than a simple shorthand
#7931
Replies: 2 comments
-
There are bugs in autocompletion that needs to be addressed. In particular, getting the node on a typed readonly variable should be enough to have full autocompletion (but currently it isn't). I would like to have a warning (that could be configured to an error via settings) in the editor, if an script attached to a node uses either And, of course, the warning could not be shown if the script is being edited in a context where no node having it attached is available. Since an script could be attached to multiple nodes, or none, I'm thinking this might not be an script warning, but a node warning, or both (so that the editor can point in the scene dock which node have the problem). Sadly there is no way to jump from a node warning to a line of code, which is why I suggest it might be both, however, perhaps a way to allow such jump could be devised. I would also like an option in the Godot editor that would go over every scene and every script and collect error/warnings, so that problems with parts of the code that do not execute often do not have to wait for runtime to be discovered, and me opening each scene and script manually to check weren't a thing. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
problems:
It provides warnings/errors for unsafe property and method usage: it can optionally error out on
thing.function()
ifthing
may not have a method calledfunction
at runtime. That's nice! But... it breaks the current common way of dealing with components in godot:$AnimationPlayer.play("run")
make this error show up since$AnimationPlayer
gets a Node, which may not have aplay
method at runtime...$MyNode
and then rename the node in my scene, I don't get an error until runtime. Ideally the script would be updated to accomodate for node renaming, but currently you have to press play to be reminded that you didn't rename your node in code.in 100% of the cases, getting a node with
$MyNode
is done with a node that will not be renamed, replaced or deleted willingly at runtime.That is, in 100% of the cases:
solutions proposals:
$MyNode
should provide actual type information, matching the node in question.Node
. So I'm not allowed to write$AnimationPlayer.play("...")
even though I get:$AnimationPlayer
to return something else than the animation player you put in your scene! At worst it's not there anymore and you runtime fail (and getnull
), but like... you don't replace that with aMeshInstance3D
that you rename"AnimationPlayer"
at runtime in any sane project ever made, right?$MyNode
should complain if no node called "MyNode" is there in the scene the script is attached to.$
, it's because the node is in the scene you're editing.$MyNode
to get something else than a node in the currently edited scene. (that is, you don't use$MyNode
on a generic script you'll attach to arbitrary nodes. For that you either export a variable, useget_node_or_null
or evenget_node
, but not$
.)Beta Was this translation helpful? Give feedback.
All reactions