-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Allow built in scripts to use class_name #2307
Comments
If you read the issue, it never worked. The PR you link only blocks you from using something that is broken. |
Tool mode already works in built-in scripts. |
EDIT:
This is impossible right now. There was an old issue about it: godotengine/godot#21187 As a workaround, you can instance the scene inside your class. |
@KoBeWi then consider this my proposal (which is what I made it for). I think loading things from string paths should be obsoleted anyways (unless its a resource). |
Script is a resource. And what you say doesn't make sense: there is always some path that needs to be loaded, even if you don't see it, even if it's always loaded in a global scope. You can't load something into memory without having a file path to read from. |
@pycbouh a script is a resource yes but the type is not. The idea would be that it would be compiled and linked by type. |
I don't know which languages do you mean, but you need to explicitly load scripts in all of them. Some may provide syntactic sugar where namespaces and class names are translated into file system paths, but that's irrelevant to the underlying implementation that always associates a script/class with a file. It's literally impossible to get rid of a file path, because that's where the script is defined at. "Registered classes point to scripts paths" is true for every language in existence. Because your runtime needs to know where to get a class and then load it. Unless you propose we parse and load all scripts and scenes all the time, assign them a class name and then just reference that in memory. Which would be highly inefficient. The problem that KoBeWi is describing has nothing to do with class to path association. It has to do with the fact that built-in scripts are not individual files by definition, but rather are data stored in a scene. So to load a script you need to load the whole scene, at least partially by parsing its contents to find where the script is and what it is. This is by design, of course, because that's the whole point of bundling and coupling data like that. If you want independent and fully capable scripts you should store them separately from scenes. |
@pycbouh most languages use the class name not load(...) to load the type then we can just reference nodes by class_name in the scene files and there is no need for files EDIT: if thats the case and what KoBeWi said has nothing to do with class_names then something like that should be worked on. Its a major issue that we are forced to have to have separate scripts and scenes when there really is no point due to the fact we can only have 1 script per node. it just clutters the project tree |
closing in favor of this #2612 |
I am reopening this. |
Describe the project you are working on
Spaceship game.
Describe the problem or limitation you are having in your project
I am trying to make a custom sprite layer node without needing a extra dangling script.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Allow build in scripts to be able to use
tool mode andclass_name.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
same way it would for normal scripts
If this enhancement will not be used often, can it be worked around with a few lines of script?
it would be used for custom nodes when people don't want it to have a dependency on a script
Is there a reason why this should be core and not an add-on in the asset library?
it was already in but was removed for unknown reasons
godotengine/godot#27876
The text was updated successfully, but these errors were encountered: