AoF wrote: ↑Sun Jul 07, 2019 9:04 pm
By the way, I *think* line 55 has a bug in it. It shows this: var luaResult = Lua.Run("return Dialog[" + response.destinationEntry.id + "].Show_Invalid");
Shouldn't that "Show_Invalid" be using the variable instead? If I understand this correctly, you couldn't evaluate at runtime if you changed the name of your variable.
But, as you mentioned, dialogue entry fields aren't included in saved games unless you assign a function to PersistentDataManger.GetCustomSaveData to save those fields.
You could add an OnConversationResponseMenu method to a script on the Dialogue Manager to check if the player has enough energy. If not, mark the response as invalid:
Tony Li wrote: ↑Sun Jul 07, 2019 9:08 pm
You could add an OnConversationResponseMenu method to a script on the Dialogue Manager to check if the player has enough energy. If not, mark the response as invalid:
void OnConversationResponseMenu(Response[] responses)
{
foreach (var response in responses)
{
var energyCost = Field.LookupInt(response.destinationEntry.fields, "energyCost");
if (energyCost > currentPlayerEnergy) // (example)
{
response.enabled = false;
}
}
}
I may not understand, but it doesn't seem like this solves my issues.
Whether the node is shown should depend on whether you've started the quest. Whether the node is interactive should depend on whether you have enough energy. Does this provide a way of doing this? From what I can tell, this code would show the node when it shouldn't be shown (but it will be interactive in the right circumstances).
To prepare a response menu, the Dialogue System does this:
1. Evaluates the Conditions on all nodes linked from the current subtitle. This will omit nodes whose Conditions are false -- such as if the quest hasn't been started yet. The output is a Response[] array.
2. Calls any custom OnConversationResponseMenu(Response[]) methods you've added the Dialogue Manager. You can modify the values of the Response[] array. For example, check the energyCost and set enabled=false if the player doesn't have enough energy.
3. Shows the response menu. Responses whose enabled field is true are clickable. If the enabled field is false, it's not clickable.
Oh! I thought enabled meant visible, not interactable. OK, that makes sense. I guess that means I don't need your code you gave me at the beginning, because I could just change the enabled field already.