#Accessing the Array in a Resource

2 messages · Page 1 of 1 (latest)

wise halo
#

Hello!

I am trying to list each item in an Array which was created as part of a resource.

First, I created a resource that exports an Array of Resources via

@export var party : Array[Resource]

I created another resource of characters, which has items like names, stats, etc. I created 3 .tres files with this method.

Then I created a party_members.tres which has the Array of Resources and I placed each of the character.tres inside of it. The class name for this is PartyMembers.

Finally, I am trying to test how I can access this information and that is where I have reached an impasse. I found a solution in Godot 3.0, but I can't reverse engineer it unfortunately.

Attached is the code I have in my "PartyMenu" Node2D gdscript.

When I run this code, nothing is printed in the console.

wise halo
#

I figured out how to more directly load it via not having the middle-man PartyMembers class and having the stats directly loaded into the PartyMenu node.

Is there a way to keep this middle-man PartyMembers resource and not throw it out? I wanted to be able to use it to populate both a party menu AND a combat scene in the future.

I think this is the correct way to make it so I don't need to edit the party in 2 places at once, but I'm at a loss for how to make it connect.