godot-mod-loader icon indicating copy to clipboard operation
godot-mod-loader copied to clipboard

Several mods cannot extend the same script with a `class_name`

Open ColdCalzone opened this issue 2 years ago • 3 comments

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.

ColdCalzone avatar Sep 24 '23 21:09 ColdCalzone

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.

ColdCalzone avatar Oct 10 '23 15:10 ColdCalzone

I'm currently testing some older Godot version and got this interesting error message on 4.0-RC1 image 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

KANAjetzt avatar Oct 24 '23 14:10 KANAjetzt

Updated the title for clarity. Also, see https://github.com/godotengine/godot/issues/83542 for more details about this issue.

KANAjetzt avatar Sep 02 '24 15:09 KANAjetzt

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

KANAjetzt avatar Feb 19 '25 10:02 KANAjetzt