Forum rules - please read before posting.

Disable Inventory Item Combinations?

Is there a way to disable inventory item combinations? It's not something I intend to use and it's really messing with my current system.

What I want to achieve is:

When you've got item A selected and you select item B, it shouldn't try to combine A and B, but simply select A as the new item.

Deselecting on opening the inventory menu doesn't work in this case, because if you'd turn off the inventory menu without selecting a new item you shouldn't lose the item you were holding before opening the menu.

I'm using direct control with a controller and a Unity UI menu.

Any suggestions would be appreciated :)

Comments

  • In your description, you're looking to re-select A.  That can be achieved just by unchecking Unhandled interactions deselect active item? in the Settings Manager, under Inventory settings.

    If you wanted to select B instead, you can use the OnInventoryCombine event:

    using UnityEngine;
    using AC;

    public class DisableCombine : MonoBehaviour
    {
       
        private void OnEnable ()
        {
            EventManager.OnInventoryCombine += OnInventoryCombine;
        }
       
        private void OnDisable ()
        {
            EventManager.OnInventoryCombine -= OnInventoryCombine;
        }
       
        private void OnInventoryCombine (InvItem _item, InvItem combineItem)
        {
            KickStarter.runtimeInventory.SelectItem (combineItem);
        }
       
    }

  • Nice!

    This works great. I did want to select B instead, thanks for the code. (This opens up a world for me, I have never used delegates before.)

    3 related questions:

    1. When I already have item A selected, and try to select it again, it currently deselects it. I'd rather have it do nothing and simply toggle the inventory menu off. (I'd deselect the item with a controllerbutton-input instead during gameplay)

    2. When I have an item selected and interact with a hotspot, when there is no item-interaction available, can I get it to simply trigger the usual hotspot interaction? (I am using Context-Sensitive interaction method).

    3. When I have an item selected and trigger an interaction with InteractionA input, but there is no hotspot available, how can I trigger 'Examine item'?
  • 1. The event doesn't trigger if you combine an item with itself.  I'll consider amending it so that it does.

    2. The OnHotspotInteract event can be used for clicks on the Hotspot.  You'll need to define an (empty) Unhandled Inventory Interaction for the Hotspot, though.  All Hotspot/Interaction-based events are listed in the "Interaction scripting" section of the Manual.

    3. There's no standard event for clicking on "nothing", but you can just check for the player pressing the InteractionA input like you would in any Unity project, and then check if there is no active Hotspot, and a selected item:

    if (KickStarter.playerInteraction.GetActiveHotspot () == null)
    {
        // No Hotspot selected
        if (KickStarter.runtimeInventory.SelectedItem != null)
        {
            // Inventory selected, examine it
            KickStarter.runtimeInventory.Look (KickStarter.runtimeInventory.SelectedItem);
        }
    }

  • 1. Allright, I'll keep an eye on the update details in the future.

    2. I thought of that, it works except for the hotspot label. For example, I've got a sign that the player can read, and the hotspot labels shows "Read Sign", but with an item selected it says "Use Digital Watch on Sign" instead of "Read Sign". Of course I'd want to show the prefix when an item interaction is available. Hmmm. I'll look into this. If you've got any ideas on how to approuch this, please let me know.

    3. Perfect! That's a lot easier than I expected.

    Thanks again for all the help Chris.
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.