Forum rules - please read before posting.

Need help with scrollable text history log

edited May 2020 in Technical Q&A

Hello!
Currently trying to find a cool and suitable journal solution for a project I'm working on.
When I was playing the wonderful "Eliza" game, I really liked the history log there.

https://dropbox.com/s/q139927z65cav9c/eliza_history.jpg?dl=0

And I tried to build something like that, but couldn't really figure it out.
So far I managed to setup an Unity UI menu with dynamically growing (text) content.
But adding the text lines at the right moment is the problem right now.
The lines in question would basically be all text from Dialogue-Play Speech Actions.

So far I could think of two possible ways that might work, but I'm still missing something for both.

  1. AC's Journal menu element of course, but working in a single scrollable menu, with the pages representing the text lines.

  2. The Label menu element also looks great as it also has Dialogue Line as Label Type option and therefore automatically sends the text to the History Log menu as well.
    Problem here is that it gets updated as soon as a new line arrives.
    So what I'm looking for would basically be line breaks in my history menu instead of updating.
    (A way to have additional lines in the menu that are not in the game, would be great but not super important.)

So well, would be very great, if someone had an idea and could help me with that.
Thanks, nursey

Comments

  • The OnStartSpeech event is triggered whenever a character speaks - and you can hook into it to extract both the speaking character, and their speech, to update a Text component. No need to hook the Text component itself to AC's Menu Manager.

    A tutorial on custom events (using this same event) can be found here - and more can be found in the Manual's "Custom events" chapter.

    Here's a sample script (SpeechLogger.cs) that adds such text to a supplied Text component:

    using UnityEngine;
    using UnityEngine.UI;
    using AC;
    
    public class SpeechLogger : MonoBehaviour
    {
    
        [SerializeField] private Text textToUpdate;
    
        private void OnEnable () { EventManager.OnStartSpeech += OnStartSpeech; }
    
        private void OnDisable () { EventManager.OnStartSpeech -= OnStartSpeech; }
    
        private void OnStartSpeech (Char character, string speechText, int lineID)
        {
            string newLine = (character != null) ? (character.GetName (Options.GetLanguage ()) + ": ") : string.Empty;
            newLine += speechText;
            textToUpdate += "\n" + newLine;
        }
    
    }
    
  • Hello.
    Is it possible to add the display of the selected dialog option to the above script? I would be extremely grateful for help with this.
    Thanks.

  • Yes, you can do this by hooking into the OnClickConversation event:

    using UnityEngine;
    using UnityEngine.UI;
    using AC;
    
    public class SpeechLogger : MonoBehaviour
    {
    
        [SerializeField] private Text textToUpdate;
    
        private void OnEnable ()
        {
            EventManager.OnStartSpeech += OnStartSpeech;
            EventManager.OnClickConversation += OnClickConversation;
        }
    
        private void OnDisable ()
        {
            EventManager.OnStartSpeech -= OnStartSpeech;
            EventManager.OnClickConversation -= OnClickConversation;
        }
    
        private void OnStartSpeech (Char character, string speechText, int lineID)
        {
            string newLine = (character != null) ? (character.GetName (Options.GetLanguage ()) + ": ") : string.Empty;
            newLine += speechText;
            textToUpdate += "\n" + newLine;
        }
    
        private void OnClickConversation (Conversation conversation, int optionID)
        {
            string optionLabel = conversation.GetOptionNameWithID (optionID);
            textToUpdate += "\n" + optionLabel;
        }
    
    }
    

    I'll see if this can be made optional in the Chat Log wiki page as well:
    https://adventure-creator.fandom.com/wiki/Chat_log

  • Thank alot for the quick response, Chris.

  • Hello. Sry for my english.
    The code you gave above works fine.

    But your new code from WiKi displays the Conversation Option AFTER the speech that should come after this option:
    https://adventure-creator.fandom.com/wiki/Chat_log

    Is there any way to fix this? Thanks

  • I may have been a bit premature in updating the wiki script - as it will require the upcoming v1.80 update to display in the correct order.

    In the meantime, you can hack this by opening AC's Conversation script, commenting out the two instances of:

    KickStarter.eventManager.Call_OnClickConversation (this, _option.ID);
    

    And copy/pasting a new instance of this line at the top of the function (around line 725).

  • Thx alot

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.