Hi there,
Quick one I couldn't find a specific example in the documentation.
So each of my player responses has a "Difficulty" field. From my own code how can I extract this value?
Pseudocode of what I'm after:
string diff = DialogueManager.CurrentReponses.Response1.Get("Difficulty");
Thanks,
BB
Extracting data from a response
Re: Extracting data from a response
Hi,
You can put a script with a method like this on your Dialogue Manager:
API References:
Or go through DialogueManager.CurrentConversationState yourself:
API Reference:
Or if you only want to look at the difficulty of the player's selected response after the player has selected it, you can add an OnConversationLine method:
Or look at DialogueManager.CurrentConversationState.subtitle.dialogueEntry.
You can put a script with a method like this on your Dialogue Manager:
Code: Select all
using PixelCrushers.DialogueSystem;
...
void OnConversationResponseMenu(Response[] responses) {
foreach (var response in responses) {
// This code assumes Difficulty is an int, but you can look it up as other types too:
var diff = Field.LookupInt(response.destinationEntry.fields, "Difficulty");
Debug.Log("Difficulty of response " + response.destinationEntry.DialogueText + " = " + diff);
}
}
Or go through DialogueManager.CurrentConversationState yourself:
Code: Select all
foreach (var response in DialogueManager.CurrentConversationState.pcResponses) {
var diff = Field.LookupInt(response.destinationEntry.fields, "Difficulty");
Debug.Log("Difficulty of response " + response.destinationEntry.DialogueText + " = " + diff);
}
Or if you only want to look at the difficulty of the player's selected response after the player has selected it, you can add an OnConversationLine method:
Code: Select all
void OnConversationLine(Subtitle subtitle) {
Debug.Log("Difficulty: " + Field.LookupInt(subtitle.dialogueEntry.fields, "Difficulty"));
}
-
- Posts: 91
- Joined: Tue Jul 14, 2015 8:22 am
Re: Extracting data from a response
You the man, Tony.
Re: Extracting data from a response
Glad I could help!