Forum rules - please read before posting.

Keeps running crafting OnCreate action list or null reference

edited January 2021 in Technical Q&A

This problem started when I upgraded AC to 1.72.4 from 1.68.4.

I use the crafting functionality in one place as kind of a cheaty way to implement a puzzle UI where you have to put all the pieces in the right place. There's an action list that gets run when all the ingredients are in the right place to respond to solving the puzzle. This all worked fine before upgrading to the latest version.

Now, the game keeps trying to run the OnCreate action list over and over again to the point of freezing up the game. In response to that, I put an action in that list Inventory->Crafting-> Clear recipe. This stops the issue, but now throws a null reference exception which doesn't crash the game, but I don't really like null reference exceptions.

So I made the following change to MenuCrafting.cs SetOutput() to check again for null after running the actionlist to stop the null reference exception:

        if (activeRecipe != null)
        {
            AdvGame.RunActionListAsset (activeRecipe.actionListOnCreate);

            if (activeRecipe != null)
            {
                foreach (InvItem assetItem in AdvGame.GetReferences().inventoryManager.items) 
                {
                    if (assetItem.id == activeRecipe.resultID)
                    {
                        invInstances.Add(new InvInstance(assetItem, 1));
                    }
            }
        }
        }

Is there a better way to fix this without changing the AC code?

Unity version 2020.1.13f1

Comments

  • This sounds similar to an issue that was reported earlier in relation to crafting - it's possible this has already been addressed.

    I shall send you a package to test with via PM.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.