GDScript Compilation Error : "Identifier "x" is not declared in the current scope"

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


I’m a DM using Godot to create an application to improve my DnD campaigns.

In the actual stage, I’m still developing the class diagrams and so on, but I found an error that is not, actually, an error (if I can put it like this).

I have this class called Character, which have some attributes, and its child called Dwarf.

The issue shows up when I try to use any of the Character’s attributes on Dwarf’s functions.

extends Character

class_name Dwarf

func _init().():
   Name = "Test" # just an example

The error then shows up, pointing to the line, but the code works still run fine.

There’re anyway to ignore those errors or I’m making a huge mistake that I didn’t saw yet?

What’s with

func _init().():

Is that a typo?

exuin | 2021-04-25 17:06

exuin, this is valid syntax to pass arguments to the parent constructor: GDScript basics — Godot Engine (3.3) documentation in English

However, you don’t need to do this if the parent constructor doesn’t take any arguments.

Calinou | 2021-04-25 20:36

I see it’s like super

exuin | 2021-04-25 20:38

I’m leaving this way because it will have some arguments, I’m just very confused with the error showing. ^^’

Lenacius | 2021-04-25 21:32

I had a similar strange error in the class inherited from a class inherited from the Node. The error claimed that the get_node function was not found. The solution was to fix all the errors of the parent classes

Mak | 2021-04-28 15:33