Retrieve Variable & Adding Checkbox and Radio Buttons to A Panel

Announcements, support questions, and discussion for the Dialogue System.
Mchia_Soo
Posts: 72
Joined: Sun Jun 30, 2019 11:59 pm

Retrieve Variable & Adding Checkbox and Radio Buttons to A Panel

Post by Mchia_Soo »

Hey Tony!

In my game, I have set a variable for the game score. And now, I want the score and some dialogue texts of the NPCs to be displayed on a panel at the end of the game.

How can I do this? What's in my mind is to create a new script and retrieve the variable (But how?), so that it can display on the panel.

Also I will add some checkbox and radio buttons on the same panel. Those correctly ticked buttons will be given score and the score will be displaying again in the conversation of the quest giver. (score will be displayed twice) How can I retrieve the variables from my new script to Dialogue System and from Dialogue System to that script?
[Should I use the GetVariable()? But how to use it?]
I'm sorry, I'm still new to the scripting.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Retrieve Variable & Adding Checkbox and Radio Buttons to A Panel

Post by Tony Li »

Hi,

At the top of your script, include this line:

Code: Select all

using PixelCrushers.DialogueSystem;
When you want to get the value of a Dialogue System variable, use DialogueLua.GetVariable(). You will also need to specify the type of value you want to get from the variable. For example:

Code: Select all

int score = DialogueLua.GetVariable("Score").asInt;
Mchia_Soo
Posts: 72
Joined: Sun Jun 30, 2019 11:59 pm

Re: Retrieve Variable & Adding Checkbox and Radio Buttons to A Panel

Post by Mchia_Soo »

Oh, I have missed out some information. The variable that I want to display on the panel is the variable I set at the Quest Node State/Active/Journal Text using Dialogue System Text Quest Content. And the variable will be displayed only when that particular node is Active.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Retrieve Variable & Adding Checkbox and Radio Buttons to A Panel

Post by Tony Li »

Let's say that variable is named "Score" in the Dialogue Editor.

Set the Dialogue System Text Quest Content to something like:

Code: Select all

Points: [var=Score]
The tag [var=Score] will be replaced by the value of the Score variable.
Mchia_Soo
Posts: 72
Joined: Sun Jun 30, 2019 11:59 pm

Re: Retrieve Variable & Adding Checkbox and Radio Buttons to A Panel

Post by Mchia_Soo »

Can I write the same syntax in my script as well?
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Retrieve Variable & Adding Checkbox and Radio Buttons to A Panel

Post by Tony Li »

Yes, if you run it through FormattedText.ParseCode:

Code: Select all

string s = FormattedText.ParseCode("Points: [var=Score]");
Mchia_Soo
Posts: 72
Joined: Sun Jun 30, 2019 11:59 pm

Re: Retrieve Variable & Adding Checkbox and Radio Buttons to A Panel

Post by Mchia_Soo »

I'm not sure whether I'm doing it right or not.

My game scenario: the player will choose the NPCs to talk to. I have set one Quest Node per conversation where the player will be given marks through the conversations set in Dialogue System. The Journal has also recorded the NPCs' characteristics that the player chooses to talk to.

And now, I will be doing my own script where the panel will display the characteristics of chosen NPCs (Recorded in the Journal). But the chosen NPCs' characteristics will only be displayed once that particular Quest Node is active. So what should I do? Or is there any way to ease the procedures?

Really appreciate your help!
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Retrieve Variable & Adding Checkbox and Radio Buttons to A Panel

Post by Tony Li »

Hi,

Sorry, I don't understand. Can you please provide some mock-up screenshots or drawings to help clarify? (What is a mark? What is a characteristic?)

I think you should be able to do this without any scripting, but I can't give a definitive answer until I have a better understanding of your requirements.
Mchia_Soo
Posts: 72
Joined: Sun Jun 30, 2019 11:59 pm

Re: Retrieve Variable & Adding Checkbox and Radio Buttons to A Panel

Post by Mchia_Soo »

Mark refers to the score.

And the characteristics is the physical appearance of the NPCs (For example, hairstyle) in the game. My game is to talk to the NPCs to collect the characteristics of each NPC. So yea. :)
Mchia_Soo
Posts: 72
Joined: Sun Jun 30, 2019 11:59 pm

Re: Retrieve Variable & Adding Checkbox and Radio Buttons to A Panel

Post by Mchia_Soo »

There are too many nodes I have created and the screenshot below is just part of them.
QuestEditior.JPG
QuestEditior.JPG (40.8 KiB) Viewed 874 times
I made each characteristic in one node and have set the score for every node, as shown in the screenshot below.
Inspector.JPG
Inspector.JPG (39.81 KiB) Viewed 874 times
Post Reply