"Class hides a global script class" error when inherit named class

Godot Version

Godot_v4.3-stable

Question

In short, this error arised when I inherit a named class in my script extension.

I’m new to Godot so this may be a silly question. I’ve read some answers about class name and Autoload but didn’t understand.
I’m writing a mod for a Steam 2D game. This is my first time to write a mod, so basically I just follow the tutorial on Godot Mod Loader Wiki.
All I want to do is change the behaviours of two vanilla functions: func f1 in class A and func f2 in named class B. I successfully modified func f1 but failed on f2, so I think the class type is the reason. Below is some detail.

Following the example here Script Extensions - Godot Mod Loader Wiki, I create two script extension A.gd and B.gd in my mod folder as below:
A.gd

extends “res://…/A.gd”
func f1(input1, input2):

B.gd

extends B
func f2(input1, input2):

I also tried [extends “res://…/B.gd”] in B.gd but it raised the same error. Then the two scripts were installed in mod_main.gd by:

ModLoaderMod.install_script_extension(“res://mods-unpacked/…/A.gd”)
ModLoaderMod.install_script_extension(“res://mods-unpacked/…/B.gd”)

This works well on A.gd and func f1. How can I modify f2 in my mod? Thanks.

Did you define a class_name in either of them? Can you paste your full scripts?

No. There’s no class_name in my mod scripts and this is really the full script of my res://mods-unpacked/…/B.gd:

extends B
func f2(input1, input2):

The content of f2 doesn’t matter. I’ve tried the simplest one (only super() and print()) and it raised the same error.

It turns out that named class cannot be modded by extension. Instead, hook can mod named class and I use it to modify f2 successfully. Anyway, thanks for your reply.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.