godot-mod-loader
godot-mod-loader copied to clipboard
Several mods cannot extend the same script with a `class_name`
In Godot 4, having two or more mods extend the same script causes every script after the first to be ignored. I've found that parent_script.resource_path is blank after the first extension takes over.
After modifying the apply_extension function to sidestep that issue, I found that every extension except the last one is ignored.
I've discovered the problem isn't with every script, it only happens when the script is declared with a class_name at the top, or extends a script declared with a class_name. Autoloads and regular scripts can be extended just fine.
I'm currently testing some older Godot version and got this interesting error message on 4.0-RC1
Parser Error: Could not find class "Base" in "res://base.gd"
Same in
- 4.0-beta15
- 4.0-beta14
- 4.0-beta10
- 4.0-beta8
- 4.0-beta6
4.0-beta1 / 4.0-beta3 / 4.0-beta5 No error but the second "script_extension" overrides the first one resulting in this print out:
base
extend1 - _ready()
do_stuff
The class_name has no effect on this.
https://github.com/godotengine/godot/commits/master/core/io/resource_loader.cpp
Updated the title for clarity. Also, see https://github.com/godotengine/godot/issues/83542 for more details about this issue.
Scripts with class_name still can't be extended using take_over_path / script extensions. As a workaround, we introduced Mod Hooks in #408. More details can be found on the Wiki.
Closed by #408