Godot Version
4.2.1
Question
I am trying to make a node to keep track of an turn system it reads from a group “is_in_turnorder” so i know who to include in the turn order and it checks every node and grabs their Initiative (Initiative is defined in a resource/class called AttackStat. this class/resource that is attached to each enemy/player and orders them based off of whoever has the highest Initiative stat, and then goes through the list
my issue is that from the turn system node i cant Access the resource AttackStat that is tied to the enemy node
class_name TurnQueue
var entities =
var your_turn: bool
func _ready():
entities = get_tree().get_nodes_in_group(“is_in_turnorder”)
# this correctly grabs all the entities and prints their names if asked
entities.sort_custom(_compare_speed)
# this doesn’t work i tried entities.AttackStat.sort_custom(_compare_speed)
start_turn()
func _compare_speed(a, b):
# Custom function to compare speeds
return a.speed > b.speed
I then get this error Invalid get index ‘AttackStat’ (on base: ‘Array[Node]’).
Sorry im new to godot and game dev if anyone needs more info please let me know