How to set sturcture variables under certain conditions

Hi, it’s pretty apparent that I’m doing wrong and acting amateur!

The scenario is that I have a Structure which holds some Boolean variables (unlocked songs in this case) and is responsible for save game logic.

In other blueprints, I want to check if variables have already been true or not, and if not, do something.

What I’ve done here (which looks terrible but also works) is that I made an array from my struct variables manually, then checked each for their value in a For Loop, and if the value was false, then set its index to an Integer variable.

After completion of For Loop, I used a Switch with that int variable to set the desired struct member to true and save the struct.

My question is that I want to know if there’s another way to make my life easier while using structs or not?

Maybe your problem stems from using a struct of bools?

Why not use an array of bools?

Maybe a key / value map of type string / bool

You can have the song name as the key and have the bool setting.

Easy to set and get per song. You can also iterate over the songs

This was an example, in this case, my struct contained just booleans. But I faced this problem with various type of variables so I couldnt make an array from. And the annoying part of my situation was the Switch node, and @3dRaven 's answer seems to be the solution

Thank you! Not tried yet but I can imagine the result. Looks like a logical solution.


With better view of structs.

An array of structs seems easier.
The key / value with a string key is slightly more limited. (cannot set by ref based on string keys in blueprints)

References are not important in my case, cause i just want to know if there’s still any unlocked songs or not, so key/value array is my best choice I guess.
I not yet tried the solutions as I was busy with other parts, I’ll try tomorrow and post the results.