Cannot alter variable from parent class

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

I’m building a grid-based game. I have a tile script which is extended to an actor script. This actor script is then extended to a player and an npc script.

The tile script has a variable called “block” as seen here:

@export var block : bool

I am trying to set it so that all “actor” based classes have block set to true by default:

block = true

I get the following error for both my player and npc classes:

Parse Error: Could not resolve super class inheritance from "res://actors/".

What have I done wrong?

I could not reproduce the situation. Don’t you have any other clue?

toxicvgl | 2022-12-18 22:40

I’m on the Godot 4.0 Beta, so maybe that’s why. But there’s not really much other information. :

extends Node2D

@export var block : bool = false :

extends "res://"

block = true :

extends "res://actors/"

Here’s the Error I get:

Error at (0, 0): Could not resolve super class inheritance from "res://actors/".

YangTegap | 2022-12-19 16:16

Well, that’s the error I get in the script. In the actor script itself I get an error stating: Unexpected "Identifier" in class body. and it highlights my block = true line

YangTegap | 2022-12-19 16:18

I don’t think the sentence block = true in is syntactically correct, it cannot be in preamble. We can write it in _ready() instead.
It is not important, but I am wondering why you don’t use class_name for the tile and the actor.

toxicvgl | 2022-12-19 17:27