Getting variable description in script

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
urrmurrmur
Posts: 47
Joined: Wed May 05, 2021 1:57 pm

Getting variable description in script

Post 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.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Getting variable description in script

Post 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;
urrmurrmur
Posts: 47
Joined: Wed May 05, 2021 1:57 pm

Re: Getting variable description in script

Post by urrmurrmur »

Sorry, I mistyped in my original post. I meant retrieve a variable description, not a dialogue description as I wrote originally.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Getting variable description in script

Post by Tony Li »

Hi,

It's similar:

Code: Select all

string description = DialogueManager.masterDatabase.GetVariable(variableName).Description;
urrmurrmur
Posts: 47
Joined: Wed May 05, 2021 1:57 pm

Re: Getting variable description in script

Post 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!
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Getting variable description in script

Post 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.
urrmurrmur
Posts: 47
Joined: Wed May 05, 2021 1:57 pm

Re: Getting variable description in script

Post by urrmurrmur »

Got it, thanks.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Getting variable description in script

Post by Tony Li »

Glad to help!
Post Reply