How to check if my database has a certain string as 'title'

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
CuickQat
Posts: 10
Joined: Sun Sep 08, 2024 1:34 pm

How to check if my database has a certain string as 'title'

Post by CuickQat »

Hello!

I am trying to create a script that connects third-party level editor (LDtk) and Dialogue System.
My goal is to do this:

1. write dialogueTitle string values in the level editor, for each trigger.
2. Set DIalogueSystemTrigger component's conversation field with each trigger's dialogueTitle value.
3. Call DialogueSystemTrigger with OnUse() in runtime.

while writing a script for this, I want do a safety check if the dialogueTitle is valid conversation title in the database, to make the script safe.
How should I check if my database has the conversation title?

Can you lend me some help please?
Regards.
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to check if my database has a certain string as 'title'

Post by Tony Li »

Hi,

If you want to check at runtime:

Code: Select all

bool doesConversationExist = DialogueManager.masterDatabase.GetConversation("your title") != null;
If you're using an editor script, you'll need a reference to the DialogueDatabase asset (e.g., "database" below):

Code: Select all

bool doesConversationExist = database.GetConversation("your title") != null;
CuickQat
Posts: 10
Joined: Sun Sep 08, 2024 1:34 pm

Re: How to check if my database has a certain string as 'title'

Post by CuickQat »

Works like a charm! Thanks for the help :)
Have a good day, Tony!
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to check if my database has a certain string as 'title'

Post by Tony Li »

Happy to help! Have a good day!
Post Reply