Substring replacement
Re: Substring replacement
Great! Thank you very much, your help convinced me to buy the full version as soon as possible!
Re: Substring replacement
Happy to help! And you have good timing -- it's on sale right now.
Re: Substring replacement
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?
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
Hi,
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);
Use FormattedText.Parse():
Code: Select all
// Apply [em1] formatted to text:
s = FormattedText.Parse($"{CharacterName} in [em1]{SettlementName}[/em1]").text;
Re: Substring replacement
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.
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
Hi,
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.)
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.)
Here's the info: SimStatus
Re: Substring replacement
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.
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
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:
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))]."
Code: Select all
void OnConversationLine(Subtitle subtitle)
{
subtitle.formattedText.text = subtitle.formattedText.text.
Replace("[Resource]", yourResourceText).
Replace("[City1Name]", yourCity1Text).
Replace(etc);
}