Page 1 of 2

Retrieve Variable & Adding Checkbox and Radio Buttons to A Panel

Posted: Wed Nov 27, 2019 10:32 am
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.

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

Posted: Wed Nov 27, 2019 11:08 am
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;

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

Posted: Thu Nov 28, 2019 8:55 am
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.

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

Posted: Thu Nov 28, 2019 4:40 pm
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.

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

Posted: Thu Nov 28, 2019 9:58 pm
by Mchia_Soo
Can I write the same syntax in my script as well?

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

Posted: Thu Nov 28, 2019 10:07 pm
by Tony Li
Yes, if you run it through FormattedText.ParseCode:

Code: Select all

string s = FormattedText.ParseCode("Points: [var=Score]");

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

Posted: Fri Nov 29, 2019 10:03 am
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!

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

Posted: Fri Nov 29, 2019 11:29 am
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.

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

Posted: Fri Nov 29, 2019 11:44 am
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. :)

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

Posted: Fri Nov 29, 2019 11:51 am
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 875 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 875 times