Forum rules - please read before posting.

Is there any support for TEXT INPUT for commands?

Hi… I’m thinking of starting a hobby adventure game project and
looking for game engine to do it in. I would like to build a text phaser
and use it for controlling the game, like the old Space Quest and Space
Quest 2 type thing.

I have looked into WME and Visionaire but they have no system in
place to do this kind of thing. I believe AGS can but haven’t looked to
far into it because while I want the old input style I was hoping to not
have the old school graphic look.

I would really like to use this system as from what I have seen it is very robust, but the very fact that unity obfuscates the code confuses me.

  1. Is it possible to add a text phrase and a text input system to control the game, instead / addition to the mouse controls?
  2. Is there a build in system for that in AGC for Unity?

Thanks in advance!

-Jynks

«1

Comments

  • AC provides a very basic input system, but it's more intended for simple things like allowing the player to enter their name (see this tutorial).  It's not intended to be used as a parser - and AC is not geared towards that type of game - so such a feature would need to be added on through custom scripting.

    I am not aware of any parser-based asset in Unity, but you may have better luck if you ask on the official Unity forums.  If you can get your own parser working correctly, then you should be able to have it connect with AC quite easily, since you can trigger AC's ActionLists by simply invoking their Interact function.
  • thanks.... there apears to be some text adventure game engines in unity.. maybe I could use one of them...

    Are there any tutorial series for Adventure Game Creator for Unity? Maybe a little more focused on unity beginners as well than the ones on the front page?
  • You mean for Adventure Creator?  Video and text tutorials can be found here, and the 2D video tutorial is intended for beginners.  A basic working knowledge of Unity is expected, however, but there are plenty of resources for that on Unity's site.
  • Wondering if there are any new native support/ possible workarounds for this using AC now? Wanted text inputs to launch specific Action Lists.

    As far as I can see from the name input tutorial, it only records your input and can then be only displayed back as text in a dialogue right?

  • To be more specific - I only want the text input to recognize verbs (take, observe, touch etc) when interacting with a specific hotspot in 3D space (kind of like Life is Strange) So, my system wouldn't need the player to specify a noun/object (like "take sword" for instance)
    So inputting take (or a list of other similar words like grab etc) would launch an actionlist for that verb. Observe would launch a different AL and so on.
    Any simple solution for this?

  • Text-parsing is outside of AC's scope and does involve a lot of custom behaviour - e.g. in your case, no need for a Hotspot name.

    You can still leverage the Input element type by parsing it via a custom script, however.

    For example, this script's ParseInputBox function will search the contents of an Input element for verbs associated with the last-selected Hotspot, and then run the associated interaction:

    using UnityEngine;
    using AC;
    
    public class ParseExample : MonoBehaviour
    {
    
        public string menuName;
        public string inputBoxName;
    
        public void ParseInputBox ()
        {
            Hotspot hotspot = KickStarter.playerInteraction.GetLastOrActiveHotspot ();
            if (hotspot == null) return;
    
            MenuInput menuInput = PlayerMenus.GetElementWithName (menuName, inputBoxName) as MenuInput;
            string userInput = menuInput.label;
    
            foreach (AC.Button button in hotspot.useButtons)
            {
                if (button.isDisabled) continue;
                string verb = KickStarter.cursorManager.GetLabelFromID (button.iconID);
                if (userInput.ToLower ().Contains (verb.ToLower ()))
                {
                    hotspot.RunInteraction (button);
                    return;
                }
            }
        }
    
    }
    

    To use it, attach to an empty GameObject, prefab it, and then use the Object: Call event Action to run the prefab's ParseInputBox function after the menu is closed.

  • edited August 2022

    Thanks for the script! Currently, GetLabelFromID at line 21 shows an error - "There is no argument given that corresponds to the required formal parameter 'languageNumber' of CursorManager.GetLabelFromID(int, int)"

    Edit: fixed it by adding private int languageNumber; to line 9

  • edited August 2022

    For example, this script's ParseInputBox function will search the contents of an Input element for verbs associated with the last-selected Hotspot, and then run the associated interaction

    Also, how do I associate verbs to a hotspot, in this case?

    Edit: Do you mean the "Cursor/Icon" dropdown in the Use interactions of a hotspot?

  • edited August 2022

    Omg, this actually works, perfectly! For anyone looking for a similar setup in the future, you must define "Interaction Icons" in your cursor settings and write the Label of those icons in the input field of your menu.

    Here is my setup, for reference:

    ![](Screenshot-10 Screenshot-9 "")

    Thanks @ChrisIceBox !

  • edited August 2022

    I do have an additional question - Is it possible to have one interaction for multiple inputs/ synonyms? For instance, a player might type "speak" or "chat" instead of "talk" - so I want to have a list of acceptable words for each interaction that lead to the "talk" interaction/Icon ID Label.

    GetLabelsArray maybe? Trying to figure out how to use that though.

    Something like this -

    imageimage" alt="" title="" />

  • edited August 2022

    Yes, you can convert the label text into an array using a common separator and then check each verb individually.

    For example, this'll process verb labels separated by a forward slash, i.e. "talk/chat/speak/say":

    using UnityEngine;
    using AC;
    
    public class ParseExample : MonoBehaviour
    {
    
        public string menuName;
        public string inputBoxName;
    
        public void ParseInputBox ()
        {
            Hotspot hotspot = KickStarter.playerInteraction.GetLastOrActiveHotspot ();
            if (hotspot == null) return;
    
            MenuInput menuInput = PlayerMenus.GetElementWithName (menuName, inputBoxName) as MenuInput;
            string userInput = menuInput.label;
    
            foreach (AC.Button button in hotspot.useButtons)
            {
                if (button.isDisabled) continue;
                string verbText = KickStarter.cursorManager.GetLabelFromID (button.iconID, Options.GetLanguage ());
                string[] verbsArray = verbText.Split ("/"[0]);
                foreach (string verb in verbsArray)
                {
                    if (userInput.ToLower ().Contains (verb.ToLower ()))
                    {
                        hotspot.RunInteraction (button);
                        return;
                    }
                }
            }
        }
    
    }
    
  • This is PERFECT. Thank you!!

  • It seems this script registers the input as correct/ launches the associated interaction even if the input word contains extra, incorrect alphabets.

    For example, typing either "talk" or something like "talkasdaaf" both launch the associated interaction for "talk" because this contains the right alphabets, and it doesn't mind that incorrect letters have been entered after the correct one. How can the script be changed to account for this?

  • edited August 2022

    Also, the script/ menu stops working when I switch to a Unity UI Prefab for the menu.

    Here is my menu setup -

    image
    image
    image
    image

    And also what my script looks like atm:

    using UnityEngine;
    using AC;
    
    public class ParserText : MonoBehaviour
    {
    
        public string menuName;
        public string inputBoxName;
    
        public void ParseInputBox()
        {
            Hotspot hotspot = KickStarter.playerInteraction.GetLastOrActiveHotspot();
            if (hotspot == null) return;
    
            MenuInput menuInput = PlayerMenus.GetElementWithName(menuName, inputBoxName) as MenuInput;
            string userInput = menuInput.label;
    
            foreach (AC.Button button in hotspot.useButtons)
            {
                if (button.isDisabled) continue;
                string verbText = KickStarter.cursorManager.GetLabelFromID(button.iconID, Options.GetLanguage());
                string[] verbsArray = verbText.Split(","[0]);
                foreach (string verb in verbsArray)
                {
                    if (userInput.ToLower().Contains(verb.ToLower()))
                    {
                        PlayerMenus.GetMenuWithName("InputText").TurnOff();
                        hotspot.RunInteraction(button);
                        return;
                    }
    
                    else
                    {
                        AC.MenuInput inputBox = (AC.MenuInput)AC.PlayerMenus.GetElementWithName("InputText", "Input");
                        inputBox.label = "";
                        return;
                    }
                }
            }
        }
    
    }
    

    Note that using the method suggested above by you worked perfectly when the menu was an AC menu. Since switching to the Unity UI Prefab based, pressing Okay/Submit after typing does nothing - the button is being pressed, but the associated interaction doesn't run. There are no console errors either.

    Edit:

    Odd, there is in fact this error that pops up as soon as I type the last alphabet of "talk", without even hitting submit. This error doesn't pop up with any other word, just with the "k" of "talk". It doesn't even look related to anything:

    image

    Apologies for the small image size, seems to be a limitation of the image hosting website

  • The error messages aren't AC-related.

    To have the Input text be readable when using Unity UI, replace:

    string userInput = menuInput.label;
    

    with:

    string userInput = menuInput.GetContents ();
    

    To require the text entered to exactly match the verbs, replace:

    if (userInput.ToLower().Contains(verb.ToLower()))
    

    with:

    if (userInput.ToLower().Equals(verb.ToLower()))
    
  • edited August 2022

    Thanks! Still doesn't seem to work with Unity UI. Is it because I'm using a Text Mesh Pro Input Field?

    Edit: Oddly enough, it doesn't even allow me to drag a non-TMP input field to the AC Linked Input Field

  • Still doesn't seem to work with Unity UI. Is it because I'm using a Text Mesh Pro Input Field?

    Shouldn't factor in, but if you attach the script to your UI prefab you can bypass AC's Input element and just read the contents of the TMPro Input component directly.

    Oddly enough, it doesn't even allow me to drag a non-TMP input field to the AC Linked Input Field

    If you've added TextMeshProIsPresent to your Scripting Define Symbols (in order to let AC know TMPro can be used), you can only rely on TMPro components. It's a global switch, not one per-element.

  • If you've added TextMeshProIsPresent to your Scripting Define Symbols (in order to let AC know TMPro can be used), you can only rely on TMPro components. It's a global switch, not one per-element.

    Ok, it works by switching to a non-TMP Input field. Any idea why it might not be working with a TMP one?

    Another problem with this is that I'm only able to type within the Input field if the menu is set to Pause when enabled. This isn't needed with the AC version of the menu, it works without the game being paused.

  • Any idea why it might not be working with a TMP one?

    Try replacing AC's MenuInput script's GetContents function with the following:

    public string GetContents ()
    {
        if (uiInput)
        {
            return uiInput.text;
        }
        return label;
    }
    

    Another problem with this is that I'm only able to type within the Input field if the menu is set to Pause when enabled.

    Try using the Menu: Select element Action to force the selection.

  • It works! Thank you! The input field focus/ selection is still a little finicky, but I think I can fix that by reworking the menu a little.

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.