Hello i’m working on my own horror game and i am following this course that shows me how to do it by Aidan Perry. he showed me how to create a inventory system but not how to show it. i kinda made my own script and it works but only to the first slot can you guys please tell me how to save all the slots here is my save blueprint.
You are calling update inventory slot only on the index 0.
You probably need to loop through the indexes and update them one by one (maybe based on inventory content length? Though without information what is in UpdateInventorySlot it’s just a guess.
Also that cast seems redundant. Check the Note at the bottom of the blueprint.
Thanks for youre feedback. in the update inventory is just some code to update the interface so that the information/image/item is good (see photo below) how can i loop the index i cant find a option for that.
You can drag of the multiple squares symbol (array) from inventory slots and then call a foreach loop for it. It will have an index inside of the loop. Then try connecting the save game slot after the loop completes (there is a completed pin at the bottom of the foreach loop
Also looking at the updateinventoryslot function you seem to be setting the variable inventory to just one specific slot feed. That doesn’t seem right.
Shouldn’t the reference to inventory hold the whole inventory?
What type of variable is inventory inside of the function?
Are the inventory slots structs? The color would imply that. If so then you are already passing in inventory information into the savegame file.
To load the savegame file you need to do a bit of a different process.
You need to get the Inventory Contents from the savegame file and do a foreach loop
but in foreach loop body you have to get the element (current inventory slot struct) and convert it to the contents of the inventory slot and set it.
No, You can set Inventory slots directly from inventory content → both are arrays so one’s contents just replaces the other’s, but you need to still rebuild the ui after loading the contents.
Does it hold a struct with item information to drive it’s contents
Do you have a function call to set what is in the slot
etc. Depending on the way it’s setup you can implement a function that reconstructs the contents for instance by passing in an element from the array inventory content.
Then you would just call a loop on inventory content and pass it’s element information into the SlotArray => Get[same index as loop] => call function set slot content passing in the element.