Shopping Widget

Add a quantity check from Inventory Stash map before creating the widget, and simply don’t create it if there are no items.

1 Like

There we go.

I did another item too, but any purchased items still appear in the same order as the data table. Not that I’m totally worried about that right now, but I just want to get the technical parts out of the way first.

Now I will have to set the Sell Button to do a reverse process of the Buy Button. Well, sort of reverse. But I think I should also make a newer data table for key items (like the circuit boards and oxygen tank), since they are not meant to be consumable items.

I’ve also considered adding a button to the Inventory List widget so that some items can be used on the field or sold at a shop.

I’ve been doing some thinking about how to make it possible to sell items in possession. I could put a button into that vertical box to be replicated, except that I won’t be able to specify which item is to be sold since every button would have the exact same variable name. So what would be the best way to make individual buttons for the Inventory screen?

You need to make an intermediate storage for the items you want to sell.

Add to the widget (but strictly speaking it is better to create an additional actor that will do all the work, especially if you are planning a multiplayer mode) another variable map Name-Int, where the items from the inventory will be moved, and another Vertical Box.

In the item widget, override the On Mouse Button Double Click function.


Connect this to the Return Node to avoid the compilation warning.

In it, you need to remove one item from your inventory, and add this item to the intermediate storage. Then you need to refill both Vertical Boxes (for items in the inventory, and for items for sale).
Now, when you click the “Sell” button, you need to run a Loop on your intermediate variable, and calculate how much gold you should receive, and add it to your account.

Note that in this case, using only Name as an object identifier will not be enough.
You will need to create a structure that will contain a Reference to the Data Table and a Name.

So you’re saying I should make another widget to work with the shopping ones for selling? I’ve made more than one shop widget - a drink one, a food one and a tool one (which sells the two key items). I don’t intend to make the RPG a multiplayer one at this time, but it might still be a good idea. As for an additional variable map, would this include the item name and quantity after an item is obtained in some way?

And done. So I’m guessing this will make the compilation a little less finicky if the return node is handled?

So this would kind of refresh the vertical boxes after each purchase or when an item is used?

Thus the second Name-Int structure variable?

You need to add a place where the items you want to sell will be displayed in your store widget that you already have.
And you don’t have to (most likely don’t even need to) create several widgets to sell different products. You can limit the set of products sold when creating an instance of the widget (if your stores differ only in the list of products).

This is like a pawn shop counter. You put everything you want to sell on it (items from your inventory are moved onto the this map), and then you sell everything on the counter by pressing a button.

Here’s a good explanation:

After changing the inventory map, you need to manual refill the Vertical Boxes.
Call Clear Children for them and run the Loop again on all items in your inventory, as well as on all items “on the counter” and create widgets for each item again.

First structure Data Table reference + Name
You will need to use it as a key in your inventory map and shop counter map.

I needed to gather my thoughts before trying to figure out what you mean. I’m not sure if this is quite the right way to do it, but here is what I have so far.

In programming (as in many other activities) it is very difficult to define the concept of “right”. Here it is more like “works” or “does not work”.

To write a program (to explain to the computer what needs to be done), you first need to make step-by-step instructions that are understandable to you given programming language limitations in “choice of phrases”.
You can tell a person “sell the items from the counter”, but for a computer you need to make MORE detailed instructions, because for it there are only numbers and names of numbers (to simplify greatly).

For a computer, the instructions look like this:

  1. Take the list of items on the counter
  2. Go through each name of item in the list
  3. Take the catalog of items
  4. Find the price of one item “with that name”
  5. Find how many items “with that name” are on the counter
  6. Find how much all the items “with that name” that are on the counter will cost
  7. Add this to the total cost of goods on the counter
  8. When the list is finished, remove the items from the counter
  9. Pay for the items
  10. Draw what is on the counter now

You need to learn to break down a complex task like “make a game” into many smaller ones until it becomes understandable to the computer.
To do this, you need to watch the training lessons on the engine to understand what level of tasks it can solve, so that knowing this you know to what level you need to break down your tasks so that they become feasible.

You need to learn how to write such instructions first. Without this skill, there will be no progress.

I guess you’re talking about pseudocoding. I’m not sure which tutorials would be the best to look at, since there are so many out there. What are some the best ones most closely related to building BPs for typical traditional RPGs, if any?

I did spend two years making a playable demo in Unreal Engine, only it was just a third-person puzzle game. So I still have much to learn.

You want the ones that talk about CAPABILITIES, not how someone used them in a specific case (this is only needed as an example of work).

You don’t need a lesson on how to open a door to the unreal, you need a lesson on how to get a signal that the user pressed a button on the keyboard, how to change the roattion of the door, how to do it smoothly etc.
Knowing this, YOURSELF can make it possible for the door to be opened, and besides, if you need to open not a door but a window - you already know what to do.

This is necessary because you are unlikely to find a guide to solving your specific problem. The problems can be VERY DIFFERENT, but they can all be solved by a narrow set of general methods, which are exactly what you need to try to learn.

For example this is a cool channel that talks about the engine’s capabilities.

I tried turning the PawnInventory variable under a shop widget for the example you shared, but I can’t get a map variable out of the Inventory Struct.

I must have overlooked something. Lately, I’ve started to realize maybe I’ve been way in over my head.

Does your structure contain text (why? to work with Data Table you need Name)? Some data types (for example text) block the ability to use the structure as a map key.
Or if it’s a C++ structure, you need to add Type Hash handling.

Here is how the table based struct looks.

So would it be possible to derive the text from the Row Name?

Of course

It seems you didn’t understand what I meant when I talked about structure as a key.
You need a SEPARATE structure for the identifier (ItemID).

You also need a SEPARATE structure for the actual description of the item (it is the basis for the Data Table)


When you create an item storage (inventory, chest, shop counter) you need a map container ItemID-Int.

That is, you store as a key the Data Table in which the description is located, and the name of the row in the Data Table in which the description of the item is located.

Okay. I’ve now made the separate items and I have moved the related BP to the Game Instance and created a function for that. But I am curious: what does the custom Reset Widgets event do? Basically just restart any shop widgets?

Also, I still need to make the item window appear and have more than one clickable button. Since replicating doesn’t let me set BPs for each individual button, I’m not sure of the right method to allow the player to choose any possessed item.

This is what it SHOULD do, but in my example it’s just a placeholder with no content.
Inside, you need to clear the list of items (Vertical Box (Clear Children)) and refill it based on the current items in your inventory/on the counter/in the store.

And since this code is needed in different places, it makes sense to place it in a function so as not to copy it every time where it is needed.

Are you talking about a button for each item?
You can make a Delegate in your item widget that you call when you click on the button, and in the store widget, when creating item widgets, you can bind an event to this delegate. Through the variable, you will know which item the user clicked.

I can’t understand this, in my head this word only associates with networking. Can you use a synonym? :cold_face:

Sorry. By replicating, I meant copying the same bar and the same button in the inventory widget. In regards to the widget event, I can try creating that function and setting a node that clears the children within the inventory widget. As for the button issue, I didn’t realize I could just bind a custom event.

At some point in the future, I might find it necessary to request the help of one or two Unreal Engine experts who know more about setting up transactions and item consumption than I do; and I will need a second or third opinion on what I have so far, too.

Are you talking about purchasing items with real money?
I’m not sure, but something tells me that this is an order of magnitude more difficult than what we are doing now.

Do you want to redo everything for the third time? :sweat_smile:
I don’t want to seem like a know-it-all, but I doubt that anyone will suggest a more rational implementation option.

By the first part, I simply mean setting up a part of the BP that erases items to be sold and adds money; and erases some item when it is used or discarded or given away. And true. I don’t feel 100% confident; I did spend two years making a playable Unreal Engine demo, but it was a third-person puzzle game rather than an RPG.

As for the Reset Widgets function within the Game Instance, would it look something like this?