Forum rules - please read before posting.

Display Inventory After Adding Item

Is there a way to make the inventory display for a few seconds after an item is picked up?

- Pick up item
- Inventory appears with item highlighted to show the new item
- Inventory Automatically Closes after a few moments

is that possible?

Comments

  • Yes - if your Inventory's Appear type is set to either Manual or On Input Key, then you can use the Menu: Change state Action to turn it on, follow it up with an Engine: Pause game, and another Menu: Change state to turn it off again.

    To highlight an item, first give it an "Active texture" in the Inventory item's properties box, and use the Object: Highlight Action.
  • @ChrisIceBox is there a way to do the same with if my Inventory's appear type is set to Mouse over?
  • A Menu will still be bound by it's "Appear type" rule, so not if the mouse isn't over it.

    What you can do, however, is change this field at runtime to Manual temporarily.  Any Manager field can be accessed via script - and its API reference gotten by right-clicking the field's label.  For the default Inventory menu's Appear type field, it's:

    AC.PlayerMenus.GetMenuWithName ("Inventory").appearType

    So you can change it to Manual and Mouse Over respectively with:

    AC.PlayerMenus.GetMenuWithName ("Inventory").appearType = AppearType.Manual;

    AC.PlayerMenus.GetMenuWithName ("Inventory").appearType = AppearType.MouseOver;

    Those lines can either be placed in separate functions in a custom script and triggered with the Object: Call event Action, or placed in custom Action so that you can incorporate them directly into your ActionLists.
  • edited March 2019

    I'm trying to implement this now, however I'm still a bit lost as of how.

    I'm using the AC default Inventory menu, and my inventory's Appear type is set to Mouse over.

    I'd like to make a custom Action that does something like this:
    1. Change Inventory menu to Manual appear type.
    2. Show Inventory menu.
    3. Add item to inventory .
    4. Highlight the item (or perhaps even better scale the item graphic slightly up and down a few times to create a bounce-like effect to draw attention to it).
    5. Turn off the highlight / stop the animation.
    6. Wait for a couple of seconds.
    7. Hide Inventory menu.
    8. Change Inventory menu back to Mouse over Appear type.

    Within the Action's GUI I should be able to choose from the list of inventory items which item to affect in any given instance of the action.

    I have looked at the Custom action tutorials, however I'm still very confused about how to do something like what I've described; exactly which lines of code and where to put them in the Custom action template, etc.

  • The Scripting Guide is the place to get information about what methods are at your disposal, as well as how to access them.

    However, steps 2-7 in your list can already be performed with existing Actions. The Object: Highlight Action can be used to highlight items in the inventory.

    All you really need is an Action to change the menu's "Appear type", and use it at the start and end of an ActionList. ActionList parameters can then be used to perform the sequence on different items - see the Manual's "ActionList parameters" chapter, as well as this tutorial.

    To change the Menu's appear type in an Action, use the code above. To expose the actual appear type mode in the Action's UI, define a variable:

    public AppearType newAppearType;
    

    Then in ShowGUI ():

    newAppearType = (AppearType) EditorGUILayout.EnumPopup ("New appear type:", newAppearType);
    

    Then in Run ():

    AC.PlayerMenus.GetMenuWithName ("Inventory").appearType = newAppearType;
    
  • Okay, so in the Custom Action template the Run section now looks like this:

    override public float Run ()  
    {
        AC.PlayerMenus.GetMenuWithName("Inventory").appearType = AppearType.Manual;
        AC.PlayerMenus.GetMenuWithName("Inventory").TurnOn();
        [wait 0.5 second]
        AC.RuntimeInventory.Add(itemToAdd);
        [turn on highlighting for itemToAdd]
        [wait 2 seconds]
        [turn off highlighting for itemToAdd]
        [wait 1 second]
        AC.PlayerMenus.GetMenuWithName("Inventory").TurnOff();
        AC.PlayerMenus.GetMenuWithName("Inventory").appearType = AppearType.MouseOver;
    
        return 0f;
    }
    

    The lines in square brackets obviously need to be replaced by real code, however I haven't been able to find in the Scripting Guide how to do these.

    For the highlighting actions I take it I need to use AC.ActionHighlight, however I can't quite figure out how to use it?

    And also I haven't been able how to run the Engine: Wait action from script? I can't seem to find it in the guide.

    And finally I will need add a dropdown list to my custom action's GUI where I can select from all inventory items, and assign the selected item to the variable itemToAdd. How can I do that?

  • edited March 2019

    Again, you do not need a single custom Action to do all of these things. An Action should ideally perform one task.

    AC.ActionHighlight is named Object: Highlight in the ActionList Editor. Create this after your custom Action (which should only deal with changing the Inventory menu's "Appear type".

    Getting Actions to wait is a case of returning the time to wait in the Run function - see the comments in the provided ActionTemplate.cs file. However, it is not necessary here. Create a custom Action that changes the appear type, then use it in conjunction with Menu: Change state, Object: Highlight, Engine: Wait, Inventory: Add or remove Actions.

    Here is such an Action:
    http://pasteall.org/1563906/csharp

  • edited March 2019
    Ah okay. I just thought it would be convenient to create a single generic custom action 'Pick up item' that allows to select an inv item in the action editor GUI and then performs the whole list of actions automatically - since it will be exactly the same list of actions that is needed each time, with the specific inv item being the only variable. But of course I get the point, that it's probably bad practice to have a seemingly single action perform multiple actions behind the curtain. Thanks for clarifying the Wait thing. And thank you for your patience :) Seriously, best customer service ever!

    Then I'll just create an Action List template asset and copy it to the scene hierarchy when needed, changing only the inv item in each case. Or is there a smarter more 'official' way to do it?
  • The best way is to create a "generic" ActionList that you can recycle - changing the inv item dynamically each time. This can be done with ActionList parameters - see my comments further up.

  • Ooohh right, I had totally missed that, because I was too focused on how I THOUGHT it should be done. I'm good now, thank you!
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.