SMS-like Dialogue functions

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
orpheelyre
Posts: 4
Joined: Mon Sep 28, 2020 5:09 am

SMS-like Dialogue functions

Post by orpheelyre »

Hi Tony,

Thanks to the Dialogue System that I as a designer am able to start developing my own indie project :)

I am developing a system that contains Menu System functions and other mobile-like functions, eg. mini-game and SMS in a canvas MobileSystem. SMS consists of two panels, one is like a container of buttons that has vertically layout (similar to the SavePanel) that triggered by a "Message" button to open, and another called SMSConversationPanel is using Textline Dialogue UI script to display the conversation between the player and an NPC that triggered by a button in the MessageContainerPanel.


The questions I currently couldn't find solutions are:

1) I have no idea how to read the last entry before the player's response from a specific conversation and display it to each of the text fields of the buttons in MessageContainerPanel.

2) If I set a variable called "GetNumber" to true in a node of conversation, how do I link this conversation using other UI (customed and presented in the scene) to Textline Dialogue UI(presented in the MobileSystem Canvas). The two actors of both conversations are the same. If the variable is true, the conversation should be set active but triggered only if the player hit the related button of MessageContainerPanel.

3) How can I keep the log in Textline Dialogue? For example, when I first triggered the conversation, it displays NPC words followed by Response Menu 1) Reply later. 2) something else. But I wish the conversation could remain the state that the conversation has already been there when the player triggers the conversation to happen again. I searched for solutions and tried to tick "Use Conversation Variable" but nothing happened.

Hope that I explained clearly (apologies for my poor English :0) and appreciate again to your hard-working :)
Last edited by orpheelyre on Thu Oct 15, 2020 10:28 am, edited 2 times in total.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: SMS-like Dialogue functions

Post by Tony Li »

Hi,

Some of my answers below will suggest scripting. If you're not comfortable with scripting, you can use a visual scripting tool such as PlayMaker. The Dialogue System has integrations with several visual scripting systems.
orpheelyre wrote: Wed Oct 07, 2020 9:49 am1) I have no idea how to read the last entry before the player's response from a specific conversation and display it to each of the text fields of the buttons in MessageContainerPanel.
When the response menu starts, in C# you can check DialogueManager.currentConversationState. You can use an OnConversationResponseMenu method in a script on the Dialogue Manager GameObject. Example:

Code: Select all

void OnConversationResponseMenu(Response[] responses)
{
     DialogueEntry lastEntry = DialogueManager.currentConversationState.subtitle.dialogueEntry;
     string lastEntryText = DialogueManager.currentConversationState.subtitle.formattedText.text;
}
orpheelyre wrote: Wed Oct 07, 2020 9:49 am2) If I set a variable called "GetNumber" to true in a node of conversation, how do I link this conversation using other UI (customed and presented in the scene) to Textline Dialogue UI(presented in the MobileSystem Canvas). The two actors of both conversations are the same. If the variable is true, the conversation should be set active but triggered only if the player hit the related button of MessageContainerPanel.
If you use a Dialogue System Trigger, you can set the Conditions section. Example:

dialogueSystemTriggerVarCondition.png
dialogueSystemTriggerVarCondition.png (36.55 KiB) Viewed 1010 times

Otherwise, you can check the variable in a C# script using DialogueLua.GetVariable(). Or use the equivalent visual scripting action (e.g., in PlayMaker). Example:

Code: Select all

bool isVariableTrue = DialogueLua.GetVariable("My Variable").asBool;
orpheelyre wrote: Wed Oct 07, 2020 9:49 am3) How can I keep the log in Textline Dialogue? For example, when I first triggered the conversation, it displays NPC words followed by Response Menu 1) Reply later. 2) something else. But I wish the conversation could remain the state that the conversation has already been there when the player triggers the conversation to happen again. I searched for solutions and tried to tick "Use Conversation Variable" but nothing happened.
The TextlineDialogueUI should record the value of each conversation when you leave the scene. Make sure you've set up the save system. When the save system is set up and you leave a scene, the save system tells the TextlineDialogueUI to save the state of the current conversation's log. If you don't want to use the save system, then you can call the TextlineDialogueUI's OnRecordPersistentData() method to save the state of the current conversation. Call its OnApplyPersistentData() method to restore the saved conversation state.
orpheelyre
Posts: 4
Joined: Mon Sep 28, 2020 5:09 am

Re: SMS-like Dialogue functions

Post by orpheelyre »

Thank you very much for the rapid response!!
I'll go through your instructions to see what I can achieve. :lol:
orpheelyre
Posts: 4
Joined: Mon Sep 28, 2020 5:09 am

Re: SMS-like Dialogue functions

Post by orpheelyre »

Hi tony, sorry to bother you again. For the question #1, I assigned a new Script call ReadLastEntry to Dialogue Manager to get the lastEntryText into the text. it ended up in displaying same content for all text game objects, and displaying only after any conversation has been started.
What I am willing to do is that each text has its own conversation (controlled by different Dialogue System Triggers), the new script that attached in each text game object has,

Code: Select all

public GameObject trigger; 
which allows me to drag the game object that has a certain DialogueSystemTrigger attached.
Then I was trying to assign different conversation for each text using:

Code: Select all

var conversation = trigger.GetComponent<DialogueSystemTrigger>().conversation;
and trying to get the last entry text using the method you taught me, for example,

Code: Select all

lastEntryText = ReadLastEntry.lastEntryText;
info.text = lastEntryText;

However, currently I only know how to read the last entry of conversation that is active, or the last conversation already started. Is there a way to do something like,

Code: Select all

text = ReadLastEntry(conversation).lastEntryText;
Instead of the last entry, I would like to know how to display the specific entry by its ID. So that I would be able to get the specific entry text for different conversations and display them separatly to different textfields, whether the conversations are active or not.

Besides, there is an another problem I just found. It appears that if I enabled the Pre Delay Settings for Textline Dialogue UI, the conversation would stuck on the pre-delay icon. However, what I saw in Dialogue -> Conversations window, the node has exactly executed, just somehow didn't show up.

Your solutions to question #2 and #3 are really helpful, I've already got them work well. Thank you so much!!
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: SMS-like Dialogue functions

Post by Tony Li »

Hi,
orpheelyre wrote: Thu Oct 15, 2020 10:28 amInstead of the last entry, I would like to know how to display the specific entry by its ID. So that I would be able to get the specific entry text for different conversations and display them separatly to different textfields, whether the conversations are active or not.
I'm not sure I understand. But if you want to get the text of a specific entry, use DialogueManager.MasterDatabase.GetConversation() and/or DialogueManager.masterDatabase.GetDialogueEntry(). Examples:

Code: Select all

var entry = DialogueManager.masterDatabase.GetDialogueEntry(conversationID, dialogueEntryID);
string entryText = entry.currentDialogueText; // Gets Dialogue Text or localized version if using localization.

Code: Select all

var conversation = DialogueManager.masterDatabase.GetConversation("Title");
var entry = conversation.GetEntry(dialogueEntryID);
orpheelyre wrote: Thu Oct 15, 2020 10:28 amBesides, there is an another problem I just found. It appears that if I enabled the Pre Delay Settings for Textline Dialogue UI, the conversation would stuck on the pre-delay icon. However, what I saw in Dialogue -> Conversations window, the node has exactly executed, just somehow didn't show up.
Please compare your setup to the example included with Textline.

Also, new in version 2.2.12, the dialogue UI code in Textline is included in the Dialogue System itself. The script is called SMSDialogueUI. There is an example UI prefab in Plugins > Pixel Crushers > Dialogue System > Prefabs > Standard UI Prefabs > Pro > SMS. So you don't have to use the Textline package if you prefer to use the version that's built into the Dialogue System.
orpheelyre
Posts: 4
Joined: Mon Sep 28, 2020 5:09 am

Re: SMS-like Dialogue functions

Post by orpheelyre »

Tony Li wrote: Thu Oct 15, 2020 3:34 pm
I'm not sure I understand. But if you want to get the text of a specific entry, use DialogueManager.MasterDatabase.GetConversation() and/or DialogueManager.masterDatabase.GetDialogueEntry(). Examples:

Code: Select all

var entry = DialogueManager.masterDatabase.GetDialogueEntry(conversationID, dialogueEntryID);
string entryText = entry.currentDialogueText; // Gets Dialogue Text or localized version if using localization.

Code: Select all

var conversation = DialogueManager.masterDatabase.GetConversation("Title");
var entry = conversation.GetEntry(dialogueEntryID);
That's exactly what I'm looking for. Cheers. :lol:
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: SMS-like Dialogue functions

Post by Tony Li »

Glad to help!
Post Reply