What does this error mean?

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

I made a class_name but when I want to create an instance of it, it gives me these errors:

built-in:17 - Parse Error: The class "Pokemon" couldn't be fully loaded (script error or cyclic dependency)

 modules/gdscript/gdscript.cpp:599 - Method failed. Returning: ERR_PARSE_ERROR

this is the code for the class_name:

extends TextureButton
class_name Pokemon

var pokemon_name = ""
var stage = ""
var evolution_stage = ""
var health = 0
var type = ""
var attacks = []

func _init(var p_name, var s, var e_stage, var h, var t, var a):
    pokemon_name = p_name
    stage = s
    evolution_stage = e_stage
    health = h
    type = t
    attacks = a

in fear of sounding arrogant, it means just what it says. you have a class called Pokemon which could not be fully loaded. this might mean that there is a formatting/indentation error in the file class, if you look at your pokemon script-file there might be a red marker showing you what’s wrong with the script.

there might also be a conflict in naming, where it is referred to with different names between the file-system (what the file-name is) and the internal refference

nyan | 2021-02-10 16:43

Could you show us the code where this class is used? Btw, when the keyword class_name is used, the class script doesn’t have to be manually loaded by the script; the editor automatically makes the class script available to other scripts.

Ertain | 2021-02-10 16:17

:bust_in_silhouette: Reply From: yrtv

Cyclic dependency somewhere. But I can’t understand where. Use load instead of preload, and it will work.

P.S godot gurus, where is cyclic dependency in such simple code?

what does cyclic dependency mean?
btw I didn’t use preload or load, I used new():

var charmender = Pokemon.new("Charmender","Basic","Basic",50,"fire",charmender_attacks)

although thanks for answering!

mdubaisi | 2021-02-10 15:08

Look at example here: GDScript — Godot Engine (stable) documentation in English.

yrtv | 2021-02-10 16:16

I followed this tutorial by BornCG: https://www.youtube.com/watch?v=A60dT7RJfO8&t=2751s

mdubaisi | 2021-02-10 16:21

I watched a small part of tutorial (it’s very long) GameManager singleton(autoload) seems to be responsible for all loading and instancing done. Do you use such singleton? Attach it question.

yrtv | 2021-02-10 16:49

No. if you saw in the Game script at 32:11 he used new() as I used

mdubaisi | 2021-02-10 16:53

although thanks for spending that much time with me!

mdubaisi | 2021-02-10 16:55

He uses new() without load or preload in GameManager.gd , because GameManager.gd is Singleton.

Is your script where you use new() Singleton like his?

yrtv | 2021-02-10 18:28