Page 1 of 1

Getting variable description in script

Posted: Thu Feb 08, 2024 6:57 am
by urrmurrmur
Quick question: is there a way to retrieve a dialogue description in a script? I would like to use the description in a custom UI.

I know I can use DialogueLua.GetVariable to get a variable value, but I don't see a way to convert the Lua.Result to a DialogueSystem.Variable which would presumably give me access to the description via the fields attribute.

Re: Getting variable description in script

Posted: Thu Feb 08, 2024 9:30 am
by Tony Li
Hi,

If you know the conversation's title or ID, you can do this:

Code: Select all

string description = DialogueManager.masterDatabase.GetConversation(conversationTitle).Description;

Re: Getting variable description in script

Posted: Thu Feb 08, 2024 3:56 pm
by urrmurrmur
Sorry, I mistyped in my original post. I meant retrieve a variable description, not a dialogue description as I wrote originally.

Re: Getting variable description in script

Posted: Thu Feb 08, 2024 4:59 pm
by Tony Li
Hi,

It's similar:

Code: Select all

string description = DialogueManager.masterDatabase.GetVariable(variableName).Description;

Re: Getting variable description in script

Posted: Fri Feb 09, 2024 3:27 am
by urrmurrmur
Oh, I didn't know you could access variables via masterDatabase. I've always done it via DialogueLua. Is there a benefit to using DialogueLua for it?

Anyway, thanks for the help!

Re: Getting variable description in script

Posted: Fri Feb 09, 2024 8:06 am
by Tony Li
Hi,

Use DialogueLua to get and set the runtime values of variables.

When you read from the masterDatabase, you're reading the static info that you entered at design time, not the runtime values. Since variables' Descriptions aren't put into the runtime environment, it's okay to read them from the masterDatabase.

Re: Getting variable description in script

Posted: Sat Feb 10, 2024 8:57 am
by urrmurrmur
Got it, thanks.

Re: Getting variable description in script

Posted: Sat Feb 10, 2024 9:26 am
by Tony Li
Glad to help!