Forum rules - please read before posting.

The rope problem

Hello community.
We have a rope on the scenario. It's a simple hotspot. Our interface is always drag and drop so when you click on that item, your pointer becomes de rope. The rope can be used anywhere but we found 2 problems:

1) If I drag it to the inventory it becomes part of it! The action list currently is: Inventory, Select,Select item, Hanging rope, Ignore current inventory. Nothing else. We could very much live with it if we find a way to get it off the inventory in cases when you don't combine it with anything, for example, instead of looking for a hotspot, you just send stop pressing left click on the mouse or just press Esc to pause.
Is there a way or something to get it off on those situations in which that "inventory item" is not actually combines? Inventory Index related maybe? (it's 41).

2) Same as before, if there's a way to avoid combining against itself (disabling that hotspot temporarily). I can Send Message Turn Off but again, when not combining it against with nothing, it never gets back on. It's that moment when the drag gets cancelled that is breaking any logic I can think of.

Latest AC. Unity 2020.3.27
Thanks a lot

Comments

  • You can have a custom script run events when the item is selected/deselected, to handle things such as the turning off the associated Hotspot:

    using AC;
    using UnityEngine;
    
    public class RopeEvents : MonoBehaviour
    {
    
        public Hotspot linkedHotspot;
    
        private void OnEnable ()
        {
            EventManager.OnInventorySelect += OnInventorySelect;
            EventManager.OnInventoryDeselect += OnInventoryDeselect;
        }
    
        private void OnDisable ()
        {
            EventManager.OnInventoryDeselect -= OnInventorySelect;
            EventManager.OnInventorySelect -= OnInventoryDeselect;
        }
    
        private void OnInventorySelect (InvItem invItem)
        {
            if (invItem.id == 41)
            {
                linkedHotspot.TurnOff ();
            }
        }
    
        private void OnInventoryDeselect (InvItem invItem)
        {
            if (invItem.id == 41)
            {
                linkedHotspot.TurnOn ();
            }
        }
    
    }
    

    These same hooks could be used to alter the Inventory menu. Do you want to disable the menu's interactivity completely?

  • Hello Chris,
    As always our savior!
    Actually the script didn't work but I got the grip of it and did some changes to make it work.

    One thing:
    Unfortunately the only part I couldn't fix is that you can send it to your inventory if you drag it towards it and it gets automatically added there. I had to "LOCK" the menu for good because if not it would be added and what is worse, the hotspot disappears (gamebreaker bug). Not sure if there's a way to avoid it... Let me know. Anyways here's the full script.

    Thanks!

    using AC;
    using UnityEngine;

    public class RopeEvents : MonoBehaviour
    {
    public Hotspot linkedHotspot;

    private void OnEnable()
    {
        EventManager.OnInventorySelect += OnInventorySelect;
        EventManager.OnInventoryDeselect += OnInventoryDeselect;
        linkedHotspot.TurnOff();
    }
    
    private void OnDisable()
    {
        EventManager.OnInventorySelect -= OnInventorySelect;
        EventManager.OnInventoryDeselect -= OnInventoryDeselect;
        linkedHotspot.TurnOn();
    }
    
    private void OnInventorySelect(InvItem invItem)
    {
        if (invItem.id == 41)
        {
            linkedHotspot.TurnOff();
            PlayerMenus.GetMenuWithName("Inventory Wallet Lombardi").isLocked = true;
        }
    }
    
    private void OnInventoryDeselect(InvItem invItem)
    {
        if (invItem.id == 41)
        {
            linkedHotspot.TurnOn();
            PlayerMenus.GetMenuWithName("Inventory Wallet Lombardi").isLocked = false;
        }
    }
    

    }

  • If you want it to remain open, but prevent the Player from adding the item to it, you can alter the InventoryBox element's Prevent selection? property in the event hooks.

    Right-click the field's label to get an API reference to it that you can copy/paste into the event functions.

  • Thank you very much! Unfortunately it didn't work but it doesn't matter. We will go with the no-show approach as we are close to the deadline (Monday).

    The API it gave me was this one (below) but I could still send the rope to the inventory. Maybe it's a bug... I even clicked it true before starting the game and could play it naturally as if nothing changed (all puzzles were working and interactions as well).

    (AC.PlayerMenus.GetElementWithName("Inventory Wallet Lombardi", "Inventory Box Lombardi") as AC.MenuInventoryBox).preventSelection = true;

    Thanks 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.