Forum rules - please read before posting.

Treating input as a trigger instead of state

Hi,

since my Inventory window is working like expected I thought about pimping it by not only open and close it via an on-screen button but with a key-press, too.
So I switched the appear type of my inventory to "On input key" which perfectly works to open and close the window using a key. Then I switched the on-screen buttons click type from "run action list" to "simulate input" and defined the same input there. It works, but if I click the on-screen button the input is fired constantly, resulting in a flickering inventory window with a rnadom outcome (opened or closed). I tried both "Button" and "Axis" mode in the "Simulate" field.
Is it possible to get it working like some kind of trigger, so that the input is submitted only once when the on-screen button is clicked instead of constantly firering the simulated key to the inventory window?

Comments

  • Try switching to an "Active Input" instead of simulating the Button's input.  See the Manual chapter by the same name.
  • Thanks. Using AC for some years now and missed the basic things. Strange... ;)

    I use the same ActionList now for the key that I use for the on-screen button to open and close the inventory window. The on-screen button works for opening and closing, but the key only works for closing.

    I tried to put images here, but it doesn't seem to work anymore...
    Maybe I try again later.

  • The forum has been upgraded so the interface has changed, but images should still be embed-able. If need be, you can just post the raw links - you can't upload here but they can be posted on imgur.com and referred to in your post.

  • Embedding doesn't work anymore:
    mac-bs.de/temp/AC_ActiveInputs.png
    mac-bs.de/temp/AC_TurnInventoryOnOff.png

  • And those same Actions are run when clicking the icon in the lower-left corner?

    The Active Input is only valid during Normal gameplay. If the Inventory menu pauses the game, you'll have to define another one that is valid when Paused - but this can share the same ActionList.

  • Yes, exactly the same ActionList runs by either clicking the button and by pressing the key. The inventory window does not pause the game. As I said, closing the inventory by key works, but not opening it.

  • First of all, you can debug which Actions are actually running by toggling comments in your Actions and setting them to display at the bottom of the Settings Manager.

    Assuming the Actions are running correctly, when you run the ActionList and the inventory is off, you're unlocking "Inventory_Helper". It may be that, depending on how that's configured, it's turning off again and is closing the Inventory with it.

    Is that what's going on? Again, you can check that by inserting comments in the "Inventory_Helper" menu's ActionList when turn off.

  • I already debugged with comments and the right Actions in the ActionList are running. The ActionList in the "Inventory_Helper" menu doesn't run, like expected. To be sure I deleted the locking/unlocking Actions to only control the inventory window. All Actions are run like they should but the inventory window won't open, only close.

  • Inside Menu.cs, find the function TurnOn (around line 1818). Under this:

    if (IsOn ())
    {
        return false;
    }
    

    Paste the following:

    Debug.Log ("Turn on menu: " + title);
    

    Similarly, find the function TurnOff (around 1908). Under this:

    if (IsOff ())
    {
        return false;
    }
    

    Paste the following:

    Debug.Log ("Turn off menu: " + title);
    

    Finally, find the function ForceOff (around 1979). Under this:

    ReturnGameState ();
    

    Paste the following:

    Debug.Log ("Force off menu: " + title);
    

    Look for the relevant logs in the Console when the Inventory menu should be turned on. What do they say exacly?

  • MACMAC
    edited December 2018

    Says exactly the same, no matter if I click the on-screen button or press the key:

    When inventory should be turned on:
    _Turn On Inventory
    (From InGame_Inventory_MenuButton_OnClick , Menu: Change state)
    _
    When inventory should be turned off:
    _Turn Off Inventory
    (From InGame_Inventory_MenuButton_OnClick , Menu: Change state)
    _
    It should definetly work. I don't get it.

  • MACMAC
    edited December 2018

    By the way ... not only embedding Images doesn't work. Bold and italics text don't work, too.

    I just saw there is a complete stack. This is when pressing the key which won't work:
    Turn On Inventory
    (From InGame_Inventory_MenuButton_OnClick , Menu: Change state)

    -> AC debug logger
    UnityEngine.Debug:Log(Object, Object)
    AC.ACDebug:Log(Object, Object) (at Assets/AdventureCreator/Scripts/Static/ACDebug.cs:16)
    AC.Action:PrintComment(ActionList) (at Assets/AdventureCreator/Scripts/ActionList/Action.cs:144)
    AC.c__Iterator2:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:363)
    UnityEngine.MonoBehaviour:StartCoroutine(String, Object)
    AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:309)
    AC.ActionList:ProcessActionEnd(ActionEnd, Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:541)
    AC.ActionList:EndAction(Action) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:459)
    AC.c__Iterator2:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:428)
    UnityEngine.MonoBehaviour:StartCoroutine(String, Object)
    AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:309)
    AC.RuntimeActionList:BeginActionList(Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/RuntimeActionList.cs:135)
    AC.ActionList:Interact(Int32, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:186)
    AC.RuntimeActionList:DownloadActions(ActionListAsset, Conversation, Int32, Boolean, Boolean, Boolean) (at Assets/AdventureCreator/Scripts/ActionList/RuntimeActionList.cs:117)
    AC.AdvGame:RunActionListAsset(ActionListAsset, Conversation, Int32, Boolean, Boolean) (at Assets/AdventureCreator/Scripts/Static/AdvGame.cs:256)
    AC.AdvGame:RunActionListAsset(ActionListAsset, Int32, Int32) (at Assets/AdventureCreator/Scripts/Static/AdvGame.cs:176)
    AC.ActiveInput:TriggerIfStateMatches() (at Assets/AdventureCreator/Scripts/Input/ActiveInput.cs:177)
    AC.ActiveInput:TestForInput() (at Assets/AdventureCreator/Scripts/Input/ActiveInput.cs:157)
    AC.PlayerInput:UpdateActiveInputs() (at Assets/AdventureCreator/Scripts/Controls/PlayerInput.cs:820)
    AC.PlayerInput:UpdateInput() (at Assets/AdventureCreator/Scripts/Controls/PlayerInput.cs:758)
    AC.StateHandler:Update() (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:250)

  • not only embedding Images doesn't work. Bold and italics text don't work, too.

    The options don't appear, or they have no effect? Please post a link to a screenshot showing me how the comment editor looks for you. Other users seem to have no such issue.

    I just saw there is a complete stack. This is when pressing the key which won't work:

    This isn't from the code insertions I gave you earlier. If the new code isn't resulting in a new message, it would suggest the Menu isn't being told to turn on, or it already is on.

    You'll have to PM me a .unitypackage file of your Managers and Menu assets, as well as a test scene to experience the bug in.

  • Oh my... Maybe it's a good idea to save a script after making changes...
    The debug informations helped to find the problem: The inventory window still had the appear type "On Input Key" instead of "Manual". After changing it back to "Manual" everything works as expected now. Sometimes you don't see the forest for the trees...
    I'm sorry for wasting your time for such nonsense.

    The comment editor looks completely normal. But selecting text and then clicking the "Bold" or "Italic" button results in inserting underscores (_) around the selected text, as seen in the post above when I tried to turn the debug information to italic. When I try to embed an image, the "Image URL" pop-up opens and I can type the link to the image there, but there is no way to confirm. No button is shown and pressing enter does nothing the pop-up just stays open.

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.