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

Announcements, support questions, and discussion for the Dialogue System.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

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

Post 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.
AoF
Posts: 241
Joined: Sun May 12, 2019 8:36 pm

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

Post by AoF »

Cool, thanks!
AoF
Posts: 241
Joined: Sun May 12, 2019 8:36 pm

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

Post 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.
AoF
Posts: 241
Joined: Sun May 12, 2019 8:36 pm

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

Post by AoF »

I found the answer here: viewtopic.php?t=929
AoF
Posts: 241
Joined: Sun May 12, 2019 8:36 pm

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

Post 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);
            }
        }
    }
}


User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

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

Post by Tony Li »

Nice!
Post Reply