The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

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
Godot version 3.2.3
in Engine by (290 points)
edited by

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.

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

1 Answer

0 votes

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?

by (887 points)

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!

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

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.

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

although thanks for spending that much time with me!

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?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.