I want to make a boon picking menu like in ahdes or any other rougelike, and I made 6 Items with a recourse, and then stored them all in another resource to make an Array of them.
now I want a button to choose one of this resources form the array at random and showcase its descrption image and everything, but I don't know for the life of me how to change the labels and sprites I have in the buttons for those inside the Resources, I'm compelatly new to this, I don't know what I'm doing most of the time, and i've been trapped with this for more than a week now
here’s the script inside the button, in the right is the array resource that has the other items taht are resources as well, each of them with their description, anmes and image palce holdres
ant his is the button, pretty simple, I just want this to work so I can move on to the next part that is actually making the button do what the item is supposed to once you click it
i know tahat if i just want to cahnge it i can grab the resource and say
lable.text = resource.description
because I alredy have that resource properties filled
but I dont know how to do it when the resource in inside another resource that is an array, I have no idea, there’s no code of that because i dont know how to do it
here’s the example of waht i did taht of course doesn’t work, I think is because the random item that is picking doesn’t know the resource properties that is inside the array?
and the “pick boon” func i put it inside the array
is just a simple “pick_random()”
so it knows to pick random from insdide that array resource?
otherway it just thell me pick random doesnt exist
im lost
not much really, just created the array resource, and put the “pick random” func there because when i put it inside the button script it tells me it deson’t exist
The same way you access node.property, you can access deep resources the same way. So, it’s something like resource_array[0].nested_resource.nested_resource.property depending on what the properties of your resources are named.
Just run the code and see if it works. Even if it doesn’t, you might get some error message to share.
BoonInv is not the array, it’s a resource that contains the array. Without using the pick_boon() function, the path from the button should be Boons.Boons.pick_random() to get one of the resources from that array.