Forum rules - please read before posting.

use C# to get a speech line from an action list

edited January 1 in Technical Q&A

TL;DR: how to get a speech text as a string from an action list speech action using C#?

I added description texts for hover on hotspots (like in stasis bone totem). But as I begun to work on accessibility options I realised I want the player to be able to toggle an option to hear these descriptions read out loud by the player character. This was easy enough to do, but now I also want to use the description text from the action list speech to be used on the hover in the UI even when the speech accessibility option is not enabled. Otherwise I have the same text in the custom description component (not localised) and in the hotspot examine speech action list (localised).

Comments

  • I suppose it could also be a custom component that has the speech action features, but it seems to me using a cutscene for this is cleaner.

  • As a workaround I used a setup where I can manually set the lineID
    Descriptiontext = KickStarter.speechManager.GetLine(examineText.DescriptionLine_ID).text;
    But naturally a fully automated system would be the best.

  • If you want to make use of the localisation data, you'll need the ID from the Speech Action.

    This can be enterered manually into your ExamineText script via a public int field, once the Action's been gathered, but if you know it's always going to be e.g. the first Speech Action in a given ActionList, you can extract it through code:

    public ActionList actionList;
    public int GetSpeechID ()
    {
        foreach (AC.Action action in actionList.actions)
        {
            if (action is ActionSpeech)
            {
                return (action as ActionSpeech).lineID;
            }
        }
        return -1;
    }
    
  • Yes this is exactly what I was after!

    In my wildest dreams I could even use local variables and a variable check in the action list to get a different line of text if the item description changed, but I am not at all sure if such a feat is easily possible.

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.