My Turn Manager setget give me error Invalid set index

Godot Version

4.2.2

Question

Hello guys, I’m having trouble with my TurnManager for my battle system. This is my code for the TurnManager

extends Resource
class_name TurnManager

enum {ALLY_TURN, ENEMY_TURN, RESOLVE}

signal ally_turn_started()
signal enemy_turn_started()
signal resolve_turn_started()

var turn : int:
get:
return turn
set(value):
turn = value
match turn:
ALLY_TURN: emit_signal(“ally_turn_started”)
ENEMY_TURN: emit_signal(“enemy_turn_started”)
RESOLVE: emit_signal(“resolve_turn_started”)

This is how I am changing the turn, I have turn_manager load the TurnManager.gd script at the top and I connect to the signals in the onready function:

turn_manager.turn = TurnManager.ENEMY_TURN

When I try to run it though I get the error: Invalid set index ‘turn’ (on base: ‘GDScript’) with value of type ‘int’

You need to create a new object not just load the script. Something like: var turn_manager = load('res://TurnManager.gd').new()

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.