Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Change value of Dictionary Key-Value Pair in Blueprint

I have an ui for an inventory system, i have a container widget for each slot of my inventory, at begin play i fill a dictionnary with the slots as keys and nothing into the value.
And as for now I have this function to add a base item to my inventory.
I want to add it to the first slot that is empty. so i check if the value corresponding to the key is valid, if not it means i have room there, so i create the item and add it as child of the slot, and then i want to set it as the value coresponding to the key.
But that assignement doesnt seems to work since if i call this function several times, it always adds an item to the first slot. so the value of the key stays null.
How do you change the coresponding value of a key in a dictionnary in blueprint ? I really struggle with dictionnaries in bp in my learning process since it is not so intuitive compared to code in my opinion.
The Add Item To Slot is just a function that sets the item as child of the slot, not related to the dictionnary.
And in consequence of the problem, the printing of the index at the end always prints 0.
Thank you in advance for your further answers.

alt text

I made it so I don't have to rely on a dictionnary, but still i'd really like to know what is the actual problem I encountered,
I really like using dictionnaries in general, and i couldn't seem to find how you do that simple operation of changing the coresponding value of a key in blueprint.

Product Version: UE 4.16
dic-bp-ue4.png (110.2 kB)
more ▼

asked Feb 25 '18 at 01:48 PM in Blueprint Scripting

avatar image

16 1 1 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

hi, if your dictionary has the same key with the "Add" function it overrides, if there is not, it adds.

I hope this helps.

more ▼

answered Jun 10 '18 at 08:17 AM

avatar image

21 1 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question