Open mddm1 opened 2 months ago
What feature are you suggesting? This all sounds something you can do in scripting
there are at least 2 scripts and I have to go back and forth to see if the function I want to use in one matches the one that exists in the other. godot does not suggest the function I want to call from the other script.
Are you suggesting a feature or asking for support or ideas? You can just call another node or without anything extra, and the suggestion requires you to add type hints first or it won't show up
That sounds more like a bug report.
So to clarify:
var other : MyType
?get_node
and the hinting doesn't work? Is it in the same scene that's open in the editor?I am suggesting a feature. Yes. not using get_node.
I'm really bad with explanations so I made an image.
basically I want godot to parse the script from scene 2 that is already loaded in the scene1 script so that I can use the intel from it as a autocomplete.
You need to static type it with the class of the other node, it won't get anything else otherwise, it's just a Node3D
But please explain what the feature is, what is it you want to happen
Because if you want to have auto compete you just need to use the right type, not Node3D
but your class
Currently, in your scene2
variable, you can set any Node3D
, including any Node3D
that does not have the scene2.gd
script and does not have a function_inside_scene2
available. And I remeind you that you can change to what that scene2
variable points to at any moment, which might leave your code not working.
Instead give a custom class_name
to the scene2.gd
script (or preload
the scene2.gd
into a const
in scene_1.gd
), and define your scene2
variable to be of that class. Then, it will only be possible to set the scene2
variable to an instance of scene2.gd
which has function_inside_scene2
. And autocomplete should work (if it doe snot, you have a bug to report).
You might also want to check if the variable has a valid refrence with is_instance_valid
.
The feature you seem to be asking for would be to have autocompletion - based on the current way configured values of the variables in the inspector - without the guarantee of the variable refering to an object that would have the members you are getting autocompleted.
At least personally, I don't like the idea.
I think it would work similar to $
autocompletion. The editor is able to determine the target node type based on path. Here it would take it from an exported Node variable, which doesn't sound unreasonable.
basically I want godot to parse the script from scene 2 that is already loaded in the scene1 script so that I can use the intel from it as a autocomplete.
Currently, in your
scene2
variable, you can set anyNode3D
, including anyNode3D
that does not have thescene2.gd
script and does not have afunction_inside_scene2
available. And I remeind you that you can change to what thatscene2
variable points to at any moment, which might leave your code not working.Instead give a custom
class_name
to thescene2.gd
script (orpreload
thescene2.gd
into aconst
inscene_1.gd
), and define yourscene2
variable to be of that class. Then, it will only be possible to set thescene2
variable to an instance ofscene2.gd
which hasfunction_inside_scene2
. And autocomplete should work (if it doe snot, you have a bug to report)._You might also want to check if the variable has a valid refrence with
is_instance_valid
._The feature you seem to be asking for would be to have autocompletion - based on the current way configured values of the variables in the inspector - without the guarantee of the variable refering to an object that would have the members you are getting autocompleted.
At least personally, I don't like the idea.
I know about the making of a class_name but this would, in this case, be a workaround. This would be just a quality of life feature, I know that some scene would not even have a script to parse or the script might not have functions and so on. In this case Godot would not do anything. It would be nice for the engine to show what options are there, especially when one can have many scripts and forgets which one has the desired function.
Issue name completely unrelated to content IMO - it should be "autocomplete across files" or something similar
I know about the making of a class_name but this would, in this case, be a workaround
I don't think it's a workaround to use the relevant feature for this, I think autocomplete for nodes in the current scene is fragile as it is, adding more to it with fetching data from other scenes not currently open would make it even harder to keep working well, static typing is there to solve these issues
This feature could be summarised as "include currently open script files as an autocompletion source".
This feature could be summarised as "include currently open script files as an autocompletion source".
This is already the case – it's based on the currently open scene in the 2D/3D editor. This is why you can still see the list of scene tabs while on the script editor, as the currently selected tab is used to infer type information from the scene's nodes.
Describe the project you are working on
normal 3d game
Describe the problem or limitation you are having in your project
i want to simply call a function from an exported variable that exists in the game but when I use the variable, the function does not autocomplete.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
some sort of search algorithm that takes the variable that already has the scene i want to call the function from and provide the intel needed.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
i have a main scene that has a script attached and inside I export a variable, a node3d for example. this node3d is another scene that has a script that has a function "revived" for example. when i call the variable and write the dot "variable." i want godot to show me all the functions i can call - in this case the function "revived" => variable.revived()
If this enhancement will not be used often, can it be worked around with a few lines of script?
no script. you just have to remember what name the function has in order to correctly call it. if you have multiple scripts from multiple scenes you go back and forth to do check work
Is there a reason why this should be core and not an add-on in the asset library?
i don't know