Forum rules - please read before posting.

Combining items in inventory closes inventory window

edited May 2018 in Technical Q&A
Hi everyone! Running into an issue with my inventory system, hopefully there's an easy fix I just haven't been able to find yet.

I have an inventory similar to Quest for Glory, with an inventory menu button to pause the game and display the inventory menu, and an exit button in the inventory menu. (image of inventory menu -- forgive the horribly temp art :) https://i.imgur.com/lcrA6Jn.jpg)

This works well enough, with players being able to select an inventory item, click the exit button to return to gameplay, then use the item on things in the environment. I have an ActionList set up to hide both the Inventory and InventoryExit buttons when you exit the inventory menu, and that same action will make the Inventory menu button reappear in the top-right.

I borrowed this behavior from another Technical Q&A thread, which was super helpful (image: https://i.imgur.com/VlzlzR6.jpg). Here is my ActionList for the InventoryExit button as well: (https://i.imgur.com/HtbWe8C.jpg)

My issue is that if I combine two items in my inventory, the inventory menu will automatically close, but the exit button will remain on screen. I've captured a video of this behavior here: https://www.dropbox.com/s/4th8k89ihjv49c2/InventoryCombine_issue.mp4?dl=0

Since the player isn't clicking a button to close the inventory, this makes sense of course. So I tried to work around this issue by adding an "ActionList when turn off" onto the Inventory menu that simply turns off the exit button if the Inventory isn't visible. Unfortunately, it appears that if you combine two items in the inventory, any ActionList that should fire when the Inventory menu turns off isn't followed. 

I ran a quick experiment by creating an "ActionList when turn off" for the Inventory that exits the game whenever the inventory menu closes. Opening and closing the inventory normally would kill the game, but combining two items in the inventory would close the inventory without killing the game, suggesting that specific behavior skips any ActionList the user may have set up.

If anyone needs any more specifics here, please let me know! Thanks!

Comments

  • What are your AC and Unity version numbers?  Let's see a screenshot of the "combine ActionList's" properties box, as well as the properties of the three Menus in question.
  • Hi Chris,

    I'm on Unity 2017.3.1f1 (Personal), and am running AC version 1.62.2.

    Here is a screenshot of the properties of the combine action from the video: https://i.imgur.com/uUpiOoS.jpg

    Here is a screenshot of the properties for the Inventory menu itself: https://i.imgur.com/bAB8IvZ.jpg

    Here is a screenshot of the properties for the Exit button that displays above the Inventory menu when it is active: https://i.imgur.com/wMfE10q.jpg

    And here is a screenshot of the properties for the "open Inventory" button that displays at the top-right during gameplay: https://i.imgur.com/MA05a8d.jpg

    If you'd like to see anything else, just let me know!
  • As your Inventory menu's Appear type is set to Manual, it shouldn't be turning off unless you explicitly tell it to.  Is that the case, and if so, how/when?

    One alternative method would be to instead set your Appear type fields to During Gameplay instead - and then control their enabled state by locking/unlocking them (which can also be done with the Menu: Change state Action).

    The advantage of this method is that the locked state will always be obeyed - so long as you lock a menu, it'll never show even if it's "Appear type" condition is met.
  • Hi Chris, apologies for the delayed response.

    To answer your initial question, the only logic I have set for the InventoryExit button is that "InventoryExit_ExitButton_OnClick" ActionList: https://imgur.com/HtbWe8C

    I've tried setting up an "ActionList when turn off" for the Inventory menu as well that is a simple one-step ActionList to turn off the InventoryExit button any time the main Inventory closes: https://i.imgur.com/5wQjFxQ.jpg

    I've tested this logic by changing it to exit the game any time the Inventory closes, and it worked in every instance of opening and then closing the Inventory, except in the instance of combining two Inventory items. In that case, the menu closes without following the "ActionList when turn off" rules.

    I'll try altering the Appear Types to During Gameplay and seeing what that does. Thanks!
  • So, quick follow-up:

    I implemented the menu systems using Lock/Unlock instead of Turn On/Turn Off as you recommended. This has successfully fixed the issue of the InventoryExit button remaining visible when two objects in the inventory are combined. Now, when I combine items, both the Inventory menu and InventoryExit button remain on-screen until they are locked again by clicking on the Inventory Exit button.

    While this is a fix for the initial problem, it introduces a new one: having the inventory active During Gameplay means I need to use the Engine: Manage systems action to constrain player activity, but this doesn't "pause" the game, it just prevents new actions from taking place behind the menu. If a character is in the middle of movement and the Inventory is brought up, the character will continue moving in the background until they've reached their destination. This can cause issues with characters walking into/out of triggers in the background.

    I'm thinking a simple(?) solution to my problem might be to have an option to keep the Inventory menu from automatically closing on an item combine? It doesn't solve the underlying problem where the inventory menu closing after an item combination ignores any associated Turn Off actions attached to the Inventory menu, but it does prevent it from becoming an issue.
  • Again, except in some rare circumstances (that don't appear relevant here), the Menu shouldn't be turning off unless you tell it to.

    If the ActionList to turn it off isn't being run, we'll need to do some debugging to try to find out why this is happening.

    In Menu.cs, find the TurnOff method.  Just inside the first brace, paste the following:

    if (!IsOff () && title == "InventoryExit") Debug.Log ("Turning off InventoryExit now!");

    What does the Console say when the menu turns off when combining two items?

    Even in a backup/duplicate project, you should also test this in the latest release to be sure it's not a legacy bug.
  • Hm, I'm not familiar with the cs files myself, so I'm not sure what you mean by finding the TurnOff method. I haven't messed with the file prior, so if you know what line number it should be, it should be the same on my end.

    So, interesting development: I created a duplicate project and updated Adventure Creator to the latest version (1.63.2). I reverted the menus to their former behavior, so clicking the Inventory button in the top-right hides the Inventory button and Turns On the Inventory menu and InventoryExit button, and clicking the InventoryExit button Turns Off the Inventory menu and InventoryExit button, then shows the Inventory button in the top-right again.

    I combined two items in the inventory and both the Inventory menu and InventoryExit buttons properly closed, and the Inventory button re-appeared at the top-right. So far so good! Unfortunately, clicking the Inventory button to re-open the Inventory menu does nothing. So, the Inventory button is un-hiding properly, but its attached ActionList doesn't seem to be working anymore. I've attached a video demonstrating this behavior (along with a look at the InventoryButton ActionList for reference) here: https://www.dropbox.com/s/h9wx70tcpvd1how/Item_Combine_6-17.mp4?dl=0
  • The ActionList has a Menu: Check state Action for "Inventory" which, barring bugs, is probably unnecessary - since the InventoryButtyon menu shouldn't show while Inventory is on.

    Keep the ActionList Editor (with that ActionList) open at runtime - does that first Action flash blue when running?  My instinct is that it's somehow thinking the Menu is still on, but I'm still none the wiser as to why the Inventory menu itself is closing.

    In the latest release, that code above should be inserted into line 1859.
  • Aha, good catch! I removed the Menu: Check State action from the ActionList to clear up the redundancy.

    I added your bit of code to the TurnOff method at the line you asked for and recorded the following video: https://www.dropbox.com/s/t0garc77v3spnep/InventoryButton_Test_6-18.mp4?dl=0

    It seems that in normal circumstances it throws the text into the console, but on item combines it does not.
  • Righto - now, just above line 1924 in the same script (which should be the following):

    if (!ignoreActionList && actionListOnTurnOff != null && !IsFadingOut ())

    Add this line just above:

    if (title == "InventoryExit") Debug.LogWarning ("Forcing off InventoryExit now!");

    You should then get a warning message upon combining the two items.  This time, select the message in the Console window to reveal the full message - and paste the contents as a reply.
  • Here you go!

    Forcing off InventoryExit now!
    UnityEngine.Debug:LogWarning(Object)
    AC.Menu:ForceOff(Boolean) (at Assets/AdventureCreator/Scripts/Menu/Menu classes/Menu.cs:1931)
    AC.PlayerMenus:ForceOffAllMenus(Boolean) (at Assets/AdventureCreator/Scripts/Controls/PlayerMenus.cs:2721)
    AC.RuntimeInventory:Combine(InvItem, InvItem, Boolean) (at Assets/AdventureCreator/Scripts/Inventory/RuntimeInventory.cs:1209)
    AC.MenuInventoryBox:HandleDefaultClick(MouseState, Int32, AC_InteractionMethod) (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuInventoryBox.cs:688)
    AC.RuntimeInventory:ProcessInventoryBoxClick(Menu, MenuInventoryBox, Int32, MouseState) (at Assets/AdventureCreator/Scripts/Inventory/RuntimeInventory.cs:1875)
    AC.MenuInventoryBox:ProcessClick(Menu, Int32, MouseState) (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuInventoryBox.cs:1301)
    AC.PlayerMenus:CheckClick(Menu, MenuElement, Int32, MouseState) (at Assets/AdventureCreator/Scripts/Controls/PlayerMenus.cs:2218)
    AC.PlayerMenus:CheckClicks(Menu) (at Assets/AdventureCreator/Scripts/Controls/PlayerMenus.cs:1864)
    AC.PlayerMenus:CheckForInput() (at Assets/AdventureCreator/Scripts/Controls/PlayerMenus.cs:1958)
    AC.StateHandler:Update() (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:299)

  • Thanks, I'll look further into this.
  • OK.  So this is because your main Inventory pauses the game - and it's actually hard-coded to close all "pause" menus when items are combined.

    This was introduced in a (very) old release to allow for inventory menus that pause the game - but so far as I can tell it's no longer necessary now that ActionLists themselves can be set to "unfreeze" pause-mode when run.

    I will likely remove this enforcement in the next release, since the same effect can be achieved by hooking into the OnInventoryCombine custom event, and calling PlayerMenus.ForceOffAllMenus manually.
  • Sounds good, Chris! Thanks so much for looking into this. I'll make sure to grab the next release and see if that fixes the issue.
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.