SMS template - when there are new entries user didn't see

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
ukieiri
Posts: 3
Joined: Wed Feb 07, 2024 2:00 pm

SMS template - when there are new entries user didn't see

Post by ukieiri »

I have a phone in the game, where I want to see notifications about the new messages. Is there a way to learn if there are new messages in the conversations somehow?
User avatar
Tony Li
Posts: 23250
Joined: Thu Jul 18, 2013 1:27 pm

Re: SMS template - when there are new entries user didn't see

Post by Tony Li »

Hi!

First, let's say a conversation looks like this:

park.png
park.png (29.73 KiB) Viewed 5026 times

The conversation will stop at the node with the condition until IsAtPark() is true.

Here are two ideas on how to handle it:

1. You could handle it outside of the conversation. When you make whatever change causes IsAtPark() to be true, also activate a custom "new message" indicator. The conversation doesn't need to know about this.

2. Or handle it in the conversation. To do this, you'll need to get the SMSDialogueUI's
Spoiler

Code: Select all

public bool AreThereNewEntries(string conversationTitle);
    // Get the conversation's current history:
    string dialogueEntryRecords = DialogueLua.GetVariable($"DialogueEntryRecords_{conversationTitle}").asString;

    // Get the last dialogue entry in the conversation history:
    string[] values = s.Split(';');
    if (values.Count >= 3)
    {
        var conversationID = Tools.StringToInt(values[values.Length - 2]);
        var entryID = Tools.StringToInt(values[values.Length - 1]);
    }
    DialogueEntry entry = DialogueManager.masterDatabase.GetDialogueEntry(conversationID, entryID);

    // Check if any of its children are currently valid:
    foreach (Link link in entry.outgoingLinks)
    {
        DialogueEntry entry = DialogueManager.masterDatabase.GetDialogueEntry(link);
        if (Lua.IsTrue(entry.conditionsString)) return true;
    }
    
    // Otherwise no new entries are available:
    return false;
}
Post Reply