Greetings,
For practice, I’ve recreated the inventory example, but with my personal adjustments:
*I put all the code in an external event, and the inventory layout in an external scene. In the inventory code, there is code to load the external scene. This way, the inventory can be accessed from every linked scene in the game.
*I added an item that cannot be consumed when used. It only grants the effect without being removed from the inventory. Useful for reusable items.
It works great so far since it’s mainly the inventory example, but there’s just one problem…
The pre-made inventory example was supposedly not made with multiple scenes in mind.
I have two different scenes in my practice test, and a button to reset the current scene. If my inventory has one item in it, even if I didn’t save it, once I change or reset scenes and put the same item inside, it will display as two items.
Additionally, if I put an item in the inventory, save it, open a different scene or reset the scene, and then press load, then the item is loaded AND duplicated. However, once I press load a second time on the same scene, it changes back to the original value.
To test this theory, I went over to the ready made example, and added a button to reset the scene. I put two watermelons in the first slot, and then reset the scene without saving them. Once I put another watermelon in the empty slot, it displayed 3 watermelons. If you need to see this for yourself, just add a reset button to the example, and try it out.
So does anybody know how to fix this error? How can I make sure that the items can’t be duplicated when transitioning scenes or resetting the current scene?
My code is more or less the same as the inventory example, excluding the drag and delete code (I don’t need them).
Thanks