Page 2 of 2

Re: Can I have a sequence/lua that modifies the subtitle text?

Posted: Thu Jun 13, 2019 1:35 pm
by Tony Li
I've added a to-do task to expand the documentation on that. Currently, the Dialogue Editor page mentions that you can add custom fields to something by expanding its All Fields foldout. It also has a Template section that I'll try to make easier to find from other parts of the manual like you suggested.

Re: Can I have a sequence/lua that modifies the subtitle text?

Posted: Thu Jun 13, 2019 10:44 pm
by AoF
Cool, thanks!

Re: Can I have a sequence/lua that modifies the subtitle text?

Posted: Thu Jun 13, 2019 11:27 pm
by AoF
I added a field to the dialogue entry template and it seems to work whenever I create a new dialogue entry, but how do I get all the existing dialogue entries to have this field? I think that would be worth explaining in the template section of the documentation.

Re: Can I have a sequence/lua that modifies the subtitle text?

Posted: Thu Jun 13, 2019 11:36 pm
by AoF
I found the answer here: viewtopic.php?t=929

Re: Can I have a sequence/lua that modifies the subtitle text?

Posted: Fri Jun 14, 2019 12:03 am
by AoF
Oh yeah, one part here was missing: How do I subtract the energy when you select the response? This is how:

Code: Select all

using PixelCrushers.DialogueSystem;
using UnityEngine;

public class ShowEnergyCostInResponseMenu : MonoBehaviour
{
    private const string sprite = "<sprite=\"Energy Symbol\" name=\"Energy Symbol\">";
    private static UnityEngine.Events.UnityAction subtractEnergyCall = () => TotalEnergy.SubtractEnergy();

    public void OnConversationResponseMenu(Response[] responses)
    {
        foreach (var response in responses)
        {
            var cost = Field.LookupInt(response.destinationEntry.fields, "energyCost");

            if (cost > 0)
            {
                response.formattedText.text = sprite + response.formattedText.text;
                response.destinationEntry.onExecute.RemoveListener(subtractEnergyCall);
                response.destinationEntry.onExecute.AddListener(subtractEnergyCall);
            }
        }
    }
}



Re: Can I have a sequence/lua that modifies the subtitle text?

Posted: Fri Jun 14, 2019 9:02 am
by Tony Li
Nice!