Page 1 of 1

Yarn2: Build-In Functions do not work

Posted: Tue Nov 28, 2023 10:03 am
by kko828
Hi, thank you for your continues support.

Today, I've tried several Built-In Functions in Yarn2, but none of them seem to work. Are these functions unavailable in your system?

Here's my .yarn file:

Code: Select all

title: BuildInFunc_Test
---
My lucky number is {random_range(1, 10)}!

<<if not visited("BuildInFunc_Test") >>
    This is your first visit.
<<elseif visited_count("BuildInFunc_Test") == 1>>
    This is your 2nd visit.
<<elseif visited_count("BuildInFunc_Test") == 2>>
    This is your 3rd visit.
<<else>>
    You have visited more than 4 times.
<<endif>>
===
The result is:
1. random_range(1, 10) is parsed as "{0}" when I import it into Dialogue System. The dialogue always says "My lucky number is {0}!"
2. visited() and visited_count() are parsed as Conditions when I import it, but they don't seem to work properly. The dialogue always says "You have visited more than 4 times."

Re: Yarn2: Build-In Functions do not work

Posted: Tue Nov 28, 2023 12:36 pm
by Tony Li
Hi,

Did you add a YarnCustomCommands component (or a custom subclass) to your Dialogue Manager GameObject?

Are there any errors or warnings in the Console window?

Re: Yarn2: Build-In Functions do not work

Posted: Wed Nov 29, 2023 7:08 am
by kko828
Oh, I didn't know i needed to add that component to DialogueManager.
I added the component and now it works.
thank you! :D

Re: Yarn2: Build-In Functions do not work

Posted: Wed Nov 29, 2023 8:42 am
by Tony Li
I'll clarify that in the manual. You're right; it's not clear at all.