Hi all
I created a script that extends Node and has a class_name of Sphere. This script then calls a function in another node called "RendererManager", which has a function called RegisterObject(obj). The idea is that the code in sphere will call this function with Self as argument, to register itself in this other class. This is done by simply adding obj to an array.
So far so good.
But then this renderermanager guy goes through all the objects in the array, and depending on what's in it does a different thing. This is where the problem lies:

for o in allObjects:
		if o is Sphere:
			print("it's a sphere!")
		else:
			print("it's something else")

This throws an error " The identifier "Sphere" isn't declared in the current scope." I also tried "Sphere" with quotation marks, and it also does not work.

I assigned both scripts to spatial nodes. I still don't quite understand what that means yet, but it seems to be a basic node so I'm using it.

It's hard for me to tell what's going wrong, since I can't see your project. You might try reloading it, if you haven't already.

I've had a lot of issues with custom classes and circular references, so I stopped checking their identity with "is". Instead, I put a parameter like "is_sphere" in the class, and check for it with "o.get('is_sphere')", which always works. I gather that godot 4.x will fix some of these problems.

cybereality Any pointers on what a better approach might be?

EDIT: how about every object having its own function that will do what it needs, and have that be called in this loop, like
for o in allObjects
o.DoTheThing()

cybereality The idea is that the Renderer class takes every object that needs to be rendered and packs all relevant information into a shader. I wanted to simply add objects to the scene and have them add themselves to this class at startup. So the renderer class can loop through all objects every frame to update the shader accordingly.

So you can have a function on a base class (like you can make a Renderable class that Sphere extends) then on that class have a render() function or load_shaders() or whatever that is abstract on the base. Though GDScript doesn't allow for pure virtual functions, you can just make it empty on the base and override it in each child class. That way you can loop through and call one function. They can either do different things or nothing (if they don't need to do anything, then don't override the base function, just put a pass in there).