Forum rules - please read before posting.

Chat Log - Only for specific speakers, or with variables?

Hello,

In my game, I currently have a notifications system that notifies the player once they have interacted with a specific item that "References to ______item have become available in your menu." I have this set up using a menu that has a label with a global variable type. Interacting with the item sets the global variable, the notification menu is set to on via an action list, and then it displays the label with the global variable in the bottom left of the screen. It disappears after a few seconds.

I want a notification log specifically for these "References have become available" updates.

To do this, I initially created another global string variable called "NotficiationLog" and added an action to my "TurnOnNotification" action list that got the previously mentioned global variable and added it to this string. However, this results in a long string with no line breaks stating "References to item1 have become available.References to item2 have become available."

I found the Chat log in the wiki, which I feel like is a good starting point - I could create a new NPC that essentially is a narrator and create a subtitles menu in the bottom left for that speaker only, and change the whole "variable setting" thing to a speaker version of it, rather than displaying a menu with text for the notifications. This would allow the chat log to work. However, there is plenty of other dialogue that could potentially happen between these notifications, and I do not want all speakers to be included in the log.

https://adventure-creator.fandom.com/wiki/Chat_log

Is there a way I can modify this script to be for specific speakers only?

Comments

  • However, this results in a long string with no line breaks stating "References to item1 have become available.References to item2 have become available."

    Have you tried preceding the added string with the new-line escape sequence, \n?

    Is there a way I can modify this script to be for specific speakers only?

    The script listens out for new speech lines via an OnStartSpeech event hook. You can start this function with a check of the speaking character, to limit it by e.g. their name:

    if (speech.GetSpeakingCharacter () == null || speech.GetSpeakingCharacter ().gameObject.name != "MyNarrator") return;
    
  • Thank you for your response and suggestions!

    The \n did not work. I am not sure if this is because it is passing within a variable into a menu label, and is not a line of dialogue? If it should work under these circumstances, then I was doing something wrong.

    Regardless, I was able to incorporate the speaker character check to create the notification log. I removed the mentions of the speaker from the script, so now it just contains the list of notification text.

    This brings me to another issue - I do not want this log visible all the time, so I linked it to an AC Menu so I could turn it on/off. However, when the menu is disabled, the TMP component does not accept input when the Notification NPC speaks, and nothing is added to the log.

    I know that the wiki for the ChatLog states "The UI can be converted to an AC Menu, but don't link the Text box itself to a Label element - only the UI canvas prefab." - so it sounds like I can't just link the text box and a label element, and set the element to invisible within the menu itself.

    Do you have any suggestions on how I could have the menu be enabled, but not have the TMP element visible (unless a button is clicked)?

  • Attaching a Canvas Group component, which has visibility and interactibility options that override its children. You can keep the UI enabled, but portions of it invisible / non-interactable this way at specific times.

  • That worked perfectly - thank you!

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.