Checking for Inheritence?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Pyhrrous

I’m running into an issue where scripts don’t seem to be checking what other scripts inherit from properly. Here’s my code:

Script A:

extends "res://Objects/Parents/"

func _ready():
	print("A: ",self is root_script)

Script B:

extends "res://Objects/Parents/"

func get_hit(other):
	print("B: ",other is root_script)

onready var root_script = get_script()

However, when I test this and run get_hit from Script B (with the node Script A as its argument), in the output I get:

A: True
B: False

Is there a proper way to test for inheritance that I’m not doing here?

:bust_in_silhouette: Reply From: Pyhrrous

Nevermind, I figured out the problem.

get_script() returns the script of the child, if called from a parent that gets inherited by the child; I was expecting get_script() to always be the value of the parent instead of the value of the child, since it was only written in the parent and never called from the child.

Replacing get_script() with load("res://Objects/Parents/") did the job and it works as expected now.