Announcements, support questions, and discussion for the Dialogue System.
kko828
Posts: 17 Joined: Sun Nov 05, 2023 1:59 am
Post
by kko828 » Sun Nov 05, 2023 2:32 am
Hi, I'm using the dialogue system toghether with Yarn2 and wanna override actor's name on some lines.
When I was using Yarn2 alone, I added a tag as shown below, parsed the tag on the C# script, and temporarily overridden the actor's name.
In .yarn file:
Code: Select all
Dude: I'm misterious guy. #display_as:???
In C#(It overrides Yarn's BaseClass):
Code: Select all
public class CharacterNameView : DialogueViewBase
{
[SerializeField]
private TextMeshProUGUI text = null!;
public override void RunLine(LocalizedLine dialogueLine, Action onDialogueLineFinished)
{
var displayAs = dialogueLine.GetTag("display_as");
if (displayAs != null)
{
text.text = displayAs;
}
else if (dialogueLine.CharacterName == null)
{
Hide();
}
else
{
Display(dialogueLine.CharacterName);
}
onDialogueLineFinished();
}
}
Is it possible to do something like this with your system?
Tony Li
Posts: 22112 Joined: Thu Jul 18, 2013 1:27 pm
Post
by Tony Li » Sun Nov 05, 2023 9:31 am
Hi,
I recommend using the
ChangeActorName() function since it will consistently change the name throughout all of the Dialogue System's subsystems, not just dialogue. The
Dialogue System Extras page has a Discover Name Example (
direct download ) that demonstrates how to use ChangeActorName(). This example doesn't use Yarn, but since it's a Lua function you can use it like any other Yarn function in <<double-angle-brackets>>.
kko828
Posts: 17 Joined: Sun Nov 05, 2023 1:59 am
Post
by kko828 » Sun Nov 12, 2023 8:20 am
Hi, thank you for your reply.
I tried ChangeActorName() but it parsed strangely and gave me an error when running play mode.
my .yarn file:
Screenshot 2023-11-12 221346.png (3.12 KiB) Viewed 929 times
it parsed as :
Screenshot 2023-11-12 221507.png (3.7 KiB) Viewed 929 times
And i got this error:
Screenshot 2023-11-12 221641.png (117.54 KiB) Viewed 929 times
Please tell me the correct way to write this command when using it with Yarn.
Also, I have an additional question.
Is there a way to access tags written in Yarn (such as #some_metadata)?
Tony Li
Posts: 22112 Joined: Thu Jul 18, 2013 1:27 pm
Post
by Tony Li » Sun Nov 12, 2023 9:13 am
Hi,
Yarn's syntax for functions is strange. Unlike standard languages such as C# and Lua, it doesn't use parentheses and commas. Try this:
Code: Select all
<<ChangeActorName MyCharacter ???>>
kko828
Posts: 17 Joined: Sun Nov 05, 2023 1:59 am
Post
by kko828 » Wed Nov 15, 2023 8:47 am
Hi, thank you for your reply.
I tried your code and it works!
Also, I have an additional question.
Is there a way to access tags written in Yarn (such as #some_metadata)?
Tony Li
Posts: 22112 Joined: Thu Jul 18, 2013 1:27 pm
Post
by Tony Li » Wed Nov 15, 2023 10:06 am
Doh, sorry, I forgot to answer that part. There isn't currently a way, but I'll add it in the next release. (I also plan to add support for the new [pause/] marker and custom markup palette tags.)
kko828
Posts: 17 Joined: Sun Nov 05, 2023 1:59 am
Post
by kko828 » Sat Nov 18, 2023 12:29 am
Wow, thank you very much. i look forward to the next release!
kko828
Posts: 17 Joined: Sun Nov 05, 2023 1:59 am
Post
by kko828 » Sun Nov 19, 2023 9:10 am
Hi, I'm facing the command parsing problem again.
My yarn file:
Code: Select all
<<mmAddItem MainInventory Apple 1)>>
Unity Error Message:
Dialogue System: Lua code 'mmAddItem('MainInventory', 'Apple', '1)')' threw exception 'Object of type 'System.String' cannot be converted to type 'System.Double'.'
It seems that the third argument is parsed as String. How can I pass non-string variable to Lua function via Yarn file?
Tony Li
Posts: 22112 Joined: Thu Jul 18, 2013 1:27 pm
Post
by Tony Li » Sun Nov 19, 2023 10:18 am
Hi,
Remove the ')'
Instead of this:
Code: Select all
<<mmAddItem MainInventory Apple 1)>>
use this:
Code: Select all
<<mmAddItem MainInventory Apple 1>>
kko828
Posts: 17 Joined: Sun Nov 05, 2023 1:59 am
Post
by kko828 » Mon Nov 20, 2023 9:34 am
Ahhhh that's a stupid mistake...
Thank you, I fixed the code and it worked.