Dynamic shop inventory

I am new but also not so new. Regardless I have bee fairly effectively chugging along on my project till now when I’ve hit a fairly large block that I just can’t seem to solve.

My Goal; Have my tower shop UMG that is 5 buttons populate with the 5 items that were rolled. Using the rolled name to find the right image to set. (This shop can be re-rolled at will, as well re-rolls on a timer.)

I have working Blueprints that currently roll 5 towers from my struct. I have them being picked up in my shop, but jumping around from different tutorials and such has only made things even harder and I am having a lot of trouble solving this.

Current BB

I am sorry but I can’t even fathom how this logic was created let alone try and help you fix it. I have never in my life seen 4 “for each loops” in a row like that. As far as I cant tell, you have 5 buttons, each button will receive a random image based off of a roll of “towers” contained in a struct? Not sure what these “towers” are a picture of the shop would help. But in any case, this is def the wrong way to go about it. Explain in more detail exactly what your setup is an what you are trying to achieve, how the rolls work, what the towers are, what is in the struct etc and then I promise you we can find something that isn’t going to have 4 loops in a row.

Of course, I knew it looked wrong but I started kinda spiraling into madness. I thought I did well up till I got to this point.

Here is the Tower Struct

Since You can’t edit tables or structs I decided to make a map that puts quantity to the name, because I want to be able to scale quantity based on how many players are playing (Though right now I am only making a singleplayer demo, one step at a time)

This is the Blueprint Shop actor. (The shop is where a player buys blueprints for a tower. Owning the blueprint allows you to build the tower in your play area.)

This is the Rarity resolving function

And this is how the chosen towers are put into an array

What I want? I want Towers from a pool to be chosen and displayed in a 5 item shop. When pulled out of the pool(Even when going into a players shop) It will - quantity. If a player re-rolls or the prepare event is executed, any not- purchased towers will have the quantity returned.

The shop will be player specific. So while the pool is shared, each player would see their own shop. (This doesn’t matter right now as it is a single player demo I’m working on)

I made a separate struct/table for the ui. to be less crowded.

tldr; you want to get a tower blueprint to be added in to your inventory. the tower you get is based on its rarity and its gonna be random right. i feel like this should be much easier. the best way to go around is to create a new project and mess about it there. if what i said at the start is what you want i might look into setting a basic bp which wont really be small or efficient but might give you an idea on how to set it up.

or are you saying that out of a list of towers you want 5 towers to be randomly selected using their rarity and can the same tower be rolled in those 5 slots?

Stage 1. A Map is made from the Name and Quantity of the DataTable. (This is for the future so I can scale how many of each blueprint exist in the game based on players in the game.

Stage 2. I use that map to randomly select 5 blueprints that have a quantity > 0 to populate an array of the chosen blueprints. It reduces the quantity in the map by 1 for each time it is rolled so that way there are no duplicates made by players, and so that all players share the same pool of towers.

Stage 3. These 5 randomly selected blueprints that are now in an array are used to populate a players blueprint shop. Where they can buy it, or not.

So I made progress. Time to move on to the next stages.

That is the solution I came to that is currently working.

But I realized I need to separate get all actors so that it does run once. This (Function?) Needs to be able to run multiple times.