So I was watching a tutorial, and I got this error when I was coding
![]()
So here is the code
@export(int) var id = 1
![]()
So here is the code
@export(int) var id = 1
Remove the (int) part.
now I’m getting the
Error at (1, 9): Could not find base class "StateMachine".
That’s a different problem for a different part of the code we can’t see.
extends StateMachine
@export var id = 1
The error is quite obvious. It cannot find the base class called StateMachine. Maybe it’s made at a later stage of whatever tutorial you’re following?
btw how do I fix the Error at (4, 13): Expected end of statement after variable declaration, found “Identifier” instead.
btw I fixed that wrong code
Without seeing your code it’s impossible to tell what’s wrong.
extends Node
class_name StateMachine
var state = null setget set_state
var previous_state = null
var states = {}
@onready var parent = get_parent()
setget is Godot 3 syntax. Afaik, it’s not used any more in Godot 4.
The proper syntax for declaring and defining setters/getters is described here:
The error about “StateMachine” class is likely because that class script contains errors and thus it cannot be fully parsed. So you first need to fix all errors in that script.
okay so what do I do with it, is there a replacement or do I just remove it
Well it depends if you need a setter. Start by just removing it.
#okay I removed it but I'm still getting this error Error at (4, 13): Expected end of statement after variable declaration, found "Identifier" instead.
extends Node
class_name StateMachine
var state = null set_state
var previous_state = null
var states = {}
You need to remove set_state as well as it’s a part of the whole setget thing.
Where are you copying this code from?
a yt tutorial
never mind,it doesn’t work
You can do this :
var state: set = set_state, get = whatever###you can maybe use set_state
this may work
I never used it before
Always make sure that the version of Godot you’re using is the exact version the tutorial is using.