Help accessing information inside of a resource

Godot Version



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
# this doesn’t work i tried entities.AttackStat.sort_custom(_compare_speed)


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

What is the error message you get when you use the first option:

When posting code use the </> button to enclose your code and format it properly.

Invalid get index 'Initiative' (on base: 'Node2D (Enemy)').

this is the information im trying to access and im trying to get it from the turnqueue

I found the issue 1 was a syntax issue i believe writing
var Initiative = attack_stat.initiative
instead of var Initiative: = attack_stat.initiative

and the other was trying to acsess the stats from the array entities instead of playing through the array and reading stats from there