Forum rules - please read before posting.

Bug or missuse? Inventory: Check Selected in Specific Category and about storing last selected item.

Current AC: 1.68.3
Unity: 2018:3.4

I'm finding a problem in order to use the action Inventory: Check Selected in Specific Category

Not sure if related, I read that some years ago there was an issue with check selected (not the in specific category). I guess was fixed anyway.

**1) **When I try to select the Category in the pop up from the action, (I see the categories, I have three, that marked as Items is the first), but when I select one, the followings alerts show in the console and I can't change the category.
Image here.

I need to check the category of item because from the various categories, only one kind of item is accepted.

PS: also touch that "include last-selected" button, doesn't change the ocurrence of the alerts.. and I don't know what its function tho.

PPS: I read the action on the manual and doesn't seems I'm missuing it but I don't know...

Why: This actionlist is about a hotspot where when I use an item (undhadled, can be any), it gets the item's name and put it into a variable component so I can make other things with it after it. The getting the name works well, meaning that when using the action the last selected item works as intended. (If items could have graphic propierties would be awesome to save a lot of scripting, so I could put a graphic from the inventory in the hotspot instead of having to script all posible items, but well, not yet (btw: thanks for the documents categories).
I digress.

2) And the reason of the previous digression is because the more I automate the process the better; I was trying to use a parametrized Remove inventory item action but I've seen that I don't know how to put "Last selected inventory item" in a parameter, the parameter just allow me to select a specific item. (And I kinda expected to being able to remove last selected item, seems kinda intuitive, as AC remembers winch is the last selected item).

Is there a way to get the last selected item to use in parameters? If not well, I have to make a script to check what specific item was used anyway in order to put the correct graphic via another action list and future actions resulting of what "item is in each placement".

Thanks!!

Comments

  • I shall attempt a recreation of the Action error message - that's indeed a bug. Can you share the error message in full (stacktrace included)?

    About the item removal - seems it would just be worth having a Remove last selected? option incorporated into the Action itself. I'll consider. Know also, however, that you can modify an ActionList's parameters - at the moment an ActionList is run - by hooking into the OnBeginActionList custom event:

    using UnityEngine;
    using AC;
    
    public class SetLastItemParameter : MonoBehaviour
    {
    
        private void OnEnable ()
        {
            EventManager.OnBeginActionList += OnBeginActionList;
        }
    
        private void OnDisable ()
        {
            EventManager.OnBeginActionList -= OnBeginActionList;
        }
    
        private void OnBeginActionList (ActionList actionList, ActionListAsset actionListAsset, int startingIndex, bool isSkipping)
        {
            if (actionList == GetComponent <ActionList>())
            {
                int itemID = KickStarter.runtimeInventory.LastSelectedItem.id;
                actionList.GetParameter ("MyParameter").SetValue (itemID);
            }
        }
    
    }
    
  • The error message in full
    https://pastebin.com/9AUre464

    I searched what stacktrace means and I'm not sure If I'm able to get it.

    Can I transform that script into a custom action? I need lot of them, specially for the next project. How hard is it to script than "just activate or deactivate a bool in the settings via script"? (the kind of custom actions I did until now)

    I hit another problem:

    https://pasteboard.co/IxpRNGJ.png

    The convert propriety to variable doesn't work with local, but works on component, and that's quite strange. (manual says it should work on local too).

    I tried to use it in an normal action list rather than a interaction to check if that could be an issue... Because the message says like I'm working with an Action list Asset instead of on scene...!

    I'm starting to think there's something bad with the scene.. but I tried in other scenes and I get the same result in both actions...

  • update: Strange, the ability to choose Local variable with the set propierty to variable appears if the Actionlist is on asset instead of scene.... that's counter intuitive.

  • Strange, the ability to choose Local variable with the set propierty to variable appears if the Actionlist is on asset instead of scene.... that's counter intuitive.

    Indeed - a bug is causing the inversion, and this will be addressed soon in the upcoming 1.69.1 update.

    Can I transform that script into a custom action? I need lot of them, specially for the next project. How hard is it to script than "just activate or deactivate a bool in the settings via script"? (the kind of custom actions I did until now)

    Again, the next update will provide a "Remove last selected?" option in the Inventory: Add or remove Action, but the actual "meat" of the script above is just the last two lines. The code before it is just hooking into the OnBeginActionList event so that it runs when the ActionList it's attached to is run.

    If this example was an Action, you can access the parameters directly because the optional AssignValues function includes the ActionList's parameters as a List:

    ActionParameter myParameter;
    override public void AssignValues (List<ActionParameter> parameters)
    {
        foreach (ActionParameter parameter in parameters)
        {
            if (parameter.label == "MyParameter")
            {
                myParameter = parameter;
            }
        }
    }
    

    You can then manipulate this parameter in the Run function:

    override public float Run ()
    {
        int itemID = KickStarter.runtimeInventory.LastSelectedItem.id;
        myParameter.SetValue (itemID);
        return 0f;
    }
    
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.