Multiple databases and custom Lua types

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
hipsterdufus
Posts: 97
Joined: Thu Aug 12, 2021 6:39 pm

Multiple databases and custom Lua types

Post by hipsterdufus »

Hello, couple more questions:

Is it generally good practice to have multiple dialogue databases such as one for cutscene dialogues and one for random dialogues? Or is there some easy way to tag dialogues within the same database so that they can be easily fetched? For example, if the player talks to an NPC I want to fetch a couple random dialogues that can be displayed. I wouldn't want to fetch a random dialogue and come back with a boss dialogue or a dialogue from a different NPC. Is there an easy way to do this or do I have to manage it in my application's code?

The other thing I noticed is for Lua methods - there are some predefined types such as Item. However I'm using my own item system. Is it possible to create a Lua template with a custom parameter type?
User avatar
Tony Li
Posts: 22159
Joined: Thu Jul 18, 2013 1:27 pm

Re: Multiple databases and custom Lua types

Post by Tony Li »

Please see Working With Multiple Databases to help you decide whether to use a single database or multiple databases.

Either way, you can put a consistent string such as "Random/" in front of the titles of random conversations. In conversation dropdown menus, they will be grouped into a submenu named "Random". To get the list of all conversations that start with "Random/", use this line of code:

Code: Select all

List<Conversation> randomConversations = DialogueManager.masterDatabase.conversations.FindAll(conversation => conversation.Title.StartsWith("Random/"));
For Lua methods -- if you're talking about registering your own C# methods with Lua, those C# methods must use base types such as bool, string, and double.

However, if you're talking about field types (Number, Text, Boolean, Item, Location, etc.), you can define custom field types.
Post Reply