Forum rules - please read before posting.

Customising Menu 'Offset Element Slot' operation via action lists?

Hi,

Using AC 1.71.8 with Unity 2019.2.10f1 in a 2D game.

I have a menu set up like an Inventory Box that I am using to display a book to the player, like this: https://imgur.com/a/aqe63Xt

The first time the player uses the book, I want to trigger certain unique actions when they turn to certain pages,
for example, triggering a little animation in the menu which changes the way the page looks and then adding an item to their inventory.

I thought that if I there was an action list to perform the same action as the menu : click type : offset menu element command then I would be able to 'program' the rest in using an action list, by selecting 'run action list' in the 'click type'. But I don't think there is this option, is there?

I guess this means that I will have to script something. Is that right?
I have not done this before with AC.
How would I get started with that process?

Thanks!

Comments

  • A custom Action could be written to offset the element, but it's easier to hook into the OnMenuElementShift custom event, which is triggered whenever a multi-slot element is offset.

    For example, you can have a script trigger an ActionList asset whenever an element named "InventoryBox" is offset. The following script, placed in the scene, would do just that:

    using UnityEngine;
    using AC;
    
    public class ActionListOnOffsetInventory : MonoBehaviour
    {
    
        public ActionListAsset actionList;
    
        private void OnEnable () { EventManager.OnMenuElementShift += OnMenuElementShift; }
        private void OnDisable () { EventManager.OnMenuElementShift -= OnMenuElementShift; }
    
    
        private void OnMenuElementShift (MenuElement _element, AC_ShiftInventory shiftType)
        {
            if (_element.title == "InventoryBox")
            {
                actionList.Interact ();
            }
        }
    
    }
    

    For more on "Custom events", see the Manual's chapter of the same name.

  • Aha. OK, that makes sense, yes, I see. So I can give the menu's inventory box a specific name and then use a script like this to trigger an action list.

    Coolio, thanks Chris. I will report back when it is underway...

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.