Godot Version
4.3
Question
Is it possible to inherit from a build-in script which saved inside a scene?
What I actually wanted is to make more build-in scripts to be more… Orginized and incapsulated. And inherit scenes and inherit scripts which stored as build-in inside parent scene. But it seems that I can not inherin build-in scripts even inside the same scene!
I can’t inherit it via path (screenshot below), class_name doesn’t work, and there is no way to choose already existed script to reuse it in the same scene on another Node. Did I understand it correctly?
Sadly built in scripts cannot be inherited, it is a known issue. The script creation panel alludes to this by merely stating “Built-in scripts have some limitations”, preferably it would state some of those limitations.
opened 01:03PM - 24 Nov 21 UTC
discussion
topic:gdscript
topic:editor
documentation
### Godot version
efd0db8
### System information
W10
### Issue descr… iption
Here's a list of known limitations of built-in scripts. It might not be complete, because built-in scripts have more issues, but the others I found seem fixable. If they turn out otherwise, I will add them here later.
We should make sure that the users know these limitations. My idea was to add a big tooltip/dialog in the script creation dialog when you click something, e.g. a button next to this warning:
![image](https://user-images.githubusercontent.com/2223172/143243377-fd034f13-f423-43f3-9fac-403999094e56.png)
The list is (including explanations and theoretical fixes):
1. _Can't open built-in scripts in external editor._ They are saved inside scene, so to edit them, you need to edit scene file.
It *is* possible to extract built-in script into temporary file and synchronize with the scene, but it's ultra hacky and overkill to implement.
2. _Can't use `class_name` in bult-in scripts._ Class names are registered as references to script files, so in this case the class would need to point to a resource inside scene. Even if it was possible, you'd need to load the whole scene each time you want to parse it.
3. _Can't create script documentation for built-in scripts._ Same reason as above. Docs are created based on script files.
4. _Built-in scripts don't list in scene dependencies if they preload something._ Again, same as above. The ResourceLoader will parse every external script referenced in the scene looking for preloads. But built-in scripts require parsing the scene itself.
5. _Built-in scripts can't be extended nor preloaded._ You can't do `extends Scene.tscn::scriptid`. Same reason as above. Parser doesn't recognize internal paths. Interestingly, using `load()` will work.
2, 3, 4 and 5 could be fixed if we had a way to partially parse a scene to load a built-in resource. For text scenes it might not be a problem, but binary scenes could be more problematic, idk. Also internal resource paths need to be recognized by the parser (right now it assumes actual file paths for `extend`, `preload` etc).
But even then, fixing 2 and 3 could cause performance issues, because every scene would need to be parsed in search of built-in scripts, so it's likely not feasible.
6. _Only GDScripts and VisualScripts can be built-in._ Not sure about GDNative, but C# requires actual script file to compile it. Maaybe it could use a fix similar to 1., i.e. save the script as temporary file and compile it, but it's not worth it, as other languages aren't supported by the script editor anyways.
EDIT:
7. _Built-in scripts don't support remote sync_ - When you edit built-in script, the changes won't be synced to the running project. Also (likely due to preload shenanigans) updating the script requires a project restart. Reloading the scene won't work.
This one is probably fixable, but right now it's a limitation.
### Steps to reproduce
1. Create built-in script.
### Minimal reproduction project
_No response_
No, you can’t.
Why not simple ctrl+c ctrl+v your actual built-in script to a normal script with a class_name and attach/inherit whatever you need? If you need the same script in lot of places that means be a build-in is not the correct option.
I just experimenting to get to know how inheritance works and what possibilities I have. Thanks!