Page 1 of 1

trouble display variable in Quest text

Posted: Thu Jan 28, 2021 8:04 pm
by Strook
Hello! Im trying to do something pretty simple, but im not really sure why it fails:

I cannot display variables in the Quest text using the [var=variableName] syntax. I doesnt work for me in the Quest description and entries, but it works fine everywhere else!

here is whats showing :
Image

Image

Thank you !

PS: I had to blur some text for reasons, but there is not special code or anything going on there :oops:

Re: trouble display variable in Quest text

Posted: Thu Jan 28, 2021 8:38 pm
by Tony Li
Hi,

Can you try backing up your project and updating to the latest version of the Dialogue System?

Re: trouble display variable in Quest text

Posted: Thu Jan 28, 2021 8:40 pm
by Strook
Will do that!

Re: trouble display variable in Quest text

Posted: Sun Feb 14, 2021 12:18 pm
by Strook
Hello! I updated and the issue persists...but it might be because im doing something wrong, maybe you can help me!

The quest UI is custom, and I fetch the quest text (description, entries, etc) manually, could it be that when I do it this way :

Code: Select all

MyTextMeshProObject.text = QuestLog.GetQuestDescription(questName);
i only get the "raw" string ?


Thanks!

Re: trouble display variable in Quest text

Posted: Sun Feb 14, 2021 2:24 pm
by Tony Li
Hi,

Code: Select all

MyTextMeshProObject.text = FormattedText.ParseCode(QuestLog.GetQuestDescription(questName));

Re: trouble display variable in Quest text

Posted: Sun Feb 14, 2021 3:50 pm
by Strook
Exactly what i needed, thanks a lot!

Re: trouble display variable in Quest text

Posted: Sun Feb 14, 2021 4:16 pm
by Strook
I have another question :oops:

I managed to get the variable properly, but if my line is something like

Code: Select all

Hello, [em3]my variable is [var=test][/em3]
FormattedText.ParseCode return "Hello, [em3]my variable is XXX[/em3]"

What I would like, would be the result string to be something like "Hello, <color=#ffc000e9>my variable is XXX</color>"
(Basically, what a standard subtitle would be doing, so Textmeshpro can apply the emphasis settings)

How would you get the variable, and the emphasis ?

Re: trouble display variable in Quest text

Posted: Sun Feb 14, 2021 4:27 pm
by Tony Li
Hi,

Use FormattedText.Parse():

Code: Select all

MyTextMeshProObject.text = FormattedText.Parse(QuestLog.GetQuestDescription(questName)).text;

Re: trouble display variable in Quest text

Posted: Sun Feb 14, 2021 4:28 pm
by Strook
oh i feel dumb, I tried FormattedText.Parse, but was not sure what to do with it after... :roll:

Thanks a lot!

Re: trouble display variable in Quest text

Posted: Sun Feb 14, 2021 7:52 pm
by Tony Li
Glad to help!