Page 2 of 7

Re: Substring replacement

Posted: Mon Aug 08, 2022 1:38 pm
by korsak42
Great! Thank you very much, your help convinced me to buy the full version as soon as possible!

Re: Substring replacement

Posted: Mon Aug 08, 2022 1:59 pm
by Tony Li
Happy to help! And you have good timing -- it's on sale right now.

Re: Substring replacement

Posted: Tue Aug 09, 2022 11:22 pm
by korsak42
Welp. One more question:
I am trying to pass variable value from Lua to C#

AcceptingQuest([var=TempQuestID]);

But it will send SyntaxError. While I was writing this post, I already solved this problem, but is it still possible to transfer variables in this way, and if so, how to write it correctly?

Also, how to use Emphasis in c#? I've send string like this $"{CharacterName} in {SettlementName}" and i want to highlight SettementName how i can do it?

Re: Substring replacement

Posted: Wed Aug 10, 2022 8:25 am
by Tony Li
Hi,
korsak42 wrote: Tue Aug 09, 2022 11:22 pmI am trying to pass variable value from Lua to C#
To get a Lua variable value in C#, use DialogueLua.GetVariable():

Code: Select all

using PixelCrushers.DialogueSystem; // (put at top of script)
...
string id = DialogueLua.GetVariable("TempQuestID").asString;
AcceptingQuest(id);
korsak42 wrote: Tue Aug 09, 2022 11:22 pmAlso, how to use Emphasis in c#? I've send string like this $"{CharacterName} in {SettlementName}" and i want to highlight SettementName how i can do it?
Use FormattedText.Parse():

Code: Select all

// Apply [em1] formatted to text:
s = FormattedText.Parse($"{CharacterName} in [em1]{SettlementName}[/em1]").text;

Re: Substring replacement

Posted: Mon Aug 22, 2022 3:30 pm
by korsak42
Hi, again! Thx for your previous response completely forgot to thank you, sorry.

I use Scrolling Dialogue Prefab and can't find option to remove delay between show subtitle and show responses. It's very annoying when I test long dialogues.
Also, what is SimStatus? i didn't find info in documentation about that.

Re: Substring replacement

Posted: Mon Aug 22, 2022 3:55 pm
by Tony Li
Hi,
korsak42 wrote: Mon Aug 22, 2022 3:30 pmI use Scrolling Dialogue Prefab and can't find option to remove delay between show subtitle and show responses. It's very annoying when I test long dialogues.

A subtitle waits for its Sequence to finish. If the Sequence field is blank, it uses the Dialogue Manager's Camera & Cutscene Settings > Default Sequence, which by default is: Delay({{end}})

This makes it delay for the duration of {{end}}, which is determined by text length and the Dialogue Manager's Subtitle Settings values. If you want to delay for the typewriter duration, try setting Min Subtitle Seconds to 0.5 and Subtitle Chars Per Second to 50. (I'm glossing over details, but you can read them here.)
korsak42 wrote: Mon Aug 22, 2022 3:30 pmAlso, what is SimStatus? i didn't find info in documentation about that.
Here's the info: SimStatus

Re: Substring replacement

Posted: Mon Sep 12, 2022 6:24 pm
by korsak42
I feel very uncomfortable asking another stupid question, but I really have a hard time understanding how OnConversationLine works.

There is a place in the dialog where randomly generated information is substituted. For example "You can buy a [Resource] in the [City1Name] for the [Price], and then sell it for the [Price] in the [City2Name]". During the dialogue, it is necessary that each word in square brackets be replaced with what is generated in the c# script.
I have several different datasets and each needs a separate method (i think). I don't really understand how exactly I should link lua and c# in this case.
I think my main problem that i don't understand how to send text from node to c# method and return it back.

Re: Substring replacement

Posted: Mon Sep 12, 2022 7:45 pm
by Tony Li
Hi,

There are two ways you can do text substitution like this: Using [lua(code)] markup tags in the text, or processing the text yourself in OnConversationLine.

If you use [lua(code)], you don't need to use OnConversationLine. Write some C# methods such as GetResourceName(), GetCityName(#), etc. Register them with Lua. Then set your Dialogue Text to something like:
  • Dialogue Text: "You can buy a [lua(GetResourceName())] in the [lua(GetCityName(1))] for the [lua(GetPurchasePrice(1))], and then sell it for the [lua(GetSalePrice(2))] in the [lua(GetCityName(2))]."
If you use OnConversationLine, you don't need to use [lua(code)]. Instead, add a script (typically on the Dialogue Manager GameObject) with an OnConversationLine(Subtitle subtitle) method. In that method, substitute strings in subtitle.formattedText.text:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    subtitle.formattedText.text = subtitle.formattedText.text.
        Replace("[Resource]", yourResourceText).
        Replace("[City1Name]", yourCity1Text).
        Replace(etc);
}

Re: Substring replacement

Posted: Mon Sep 12, 2022 8:26 pm
by korsak42
Great! Thanks!

Re: Substring replacement

Posted: Mon Sep 12, 2022 8:57 pm
by Tony Li
Glad to help!