I have an AC container with 4 slots, and it is displayed as a nest that can keep 4 eggs. Though the nest menu is only accessible from one specific scene, the container itself is a child of the player character (I need to be able to manipulate the items in the container even when the player isn't in that scene).
Eggs are a stackable item in the inventory and elsewhere, but in the nest in particular, I wanted each egg to take one slot. I managed to implement this with a custom inventory script that handles clicks on the nest container differently (selecting one egg and clicking on another won't stack them, etc).
Every in-game morning, I run a script that looks for an egg instance on each nest slot and adds +1 to their age property. Then it also looks for empty nest slots, and when it finds one, it adds one new egg instance to it - meaning the bird lays one egg every day, and we keep count of how old they are. So far so good. It all works perfectly including after scene changes.
The issue I have here is that if I save the game and then reload it, if there are two or more egg instances of the same age in the nest, then those instances will be combined into a single one and be placed in the first available slot. Eggs of different ages aren't combined (as intended), but they will still be moved to a different slot.
So if before loading I have a nest like this:
[Empty] [Egg age 0] [Egg age 1] [Egg age 0]
After loading, the nest will look like this:
[Egg age 0 x2] [Egg age 1] [Empty] [Empty]
Chris, could you change the Remember Container script to account for the exact configuration of the container?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
I'll need to recreate the issue, first. What are your AC/Unity versions, and can you share screens of the Container's Inspector, the item, its properties, and your Settings Manager?
I'm using AC 1.79.2 and Unity 2021.2.7f1.
Reproduction steps:
Also note that in the Save Game Manager, under "Persistent data", the save does seem to keep the correct information saved (i.e. this is not where the stacks are merged). Something must be going wrong when restoring the container state.
Thanks, I'll see this addressed.
Open up RememberContainer and remove the code block:
Then go up and find this line:
Just underneath, copy/paste:
Does that resolve it?
Perfect, I've tested this in a few different scenarios, and the solution held up. Thanks for this!
Hey Chris, I've run into a bug related to this fix. Using the same project as above, after making the change to the Remember script:
I've checked whether this happened before the fix, but no, it didn't. The fix introduced the bug.
Thanks, I think I see the issue - I'll delve.