Page 1 of 1
How to get conversation field by string
Posted: Thu Jul 30, 2020 4:02 am
by Krejwen
Hi,
Is it possible to get custom Conversation Field by conversation title in C#?
In the documentation I see only a method:
GetConversationField()
which take converstation ID (int).
I cannot find anything that can help me to transtale Title into the ID.
Re: How to get conversation field by string
Posted: Thu Jul 30, 2020 5:13 am
by Krejwen
I have a temporary solution:
I save reference to database where conversation is and then I get the Conversation object. However, when I try go get my custom field "Tags" I get the following error:
Dialogue System: Lua code 'return Conversation[9].Tags' threw exception 'Lookup of field 'Tags' in the table element failed because the table element itself isn't in the table.'
All conversation have Tags field and all of them have unique ID. I am not able understand where is the problem...
Re: How to get conversation field by string
Posted: Thu Jul 30, 2020 9:47 am
by Tony Li
Hi,
If you're not making runtime changes, you can get the Tags field directly from the dialogue database using
DialogueDatabase.GetConversation() to get a conversation by Title or ID:
Code: Select all
var conversation = DialogueManager.masterDatabase.GetConversation("Some Title");
string tags = conversation.LookupValue("Tags");
If you need to get the runtime value from Lua:
Code: Select all
var conversation = DialogueManager.masterDatabase.GetConversation("Some Title");
string tags = DialogueLua.GetConversationField(conversation.id, "Tags").asString;
Re: How to get conversation field by string
Posted: Fri Jul 31, 2020 4:31 am
by Krejwen
Hi,
Thanks for response.
What in case if I have many databases, e.g. DLC with additional content?
Re: How to get conversation field by string
Posted: Fri Jul 31, 2020 8:08 am
by Tony Li
Hi,
If you have multiple databases, you'll use Extra Databases to load additional databases into memory.
DialogueManager.masterDatabase will contain the content of all of the databases loaded into memory.
Re: How to get conversation field by string
Posted: Mon Aug 03, 2020 6:53 am
by Krejwen
Hi,
Thanks for info. It solve my problem!
I check in the documentation that there is info that MasterDatabase fields contains all data. However, I suggest to add this info into "Standard documentation" e.g. in the section "Working With Multiple Databases/Extra Databases".
Best!
Re: How to get conversation field by string
Posted: Mon Aug 03, 2020 7:57 am
by Tony Li
Good idea! Will do.