Announcements, support questions, and discussion for the Dialogue System.
jordyadan
Posts: 2 Joined: Fri Jul 13, 2018 1:11 pm
Post
by jordyadan » Fri Jul 13, 2018 1:36 pm
Hello,
I've been trying to use if statements in the Dialogue Entry's Text and Script sections with no success. What I'm trying to do is access a boolean variable called "Test" and choose an outcome based on wether it is true or false.
Here's my Dialogue Text:
Code: Select all
Test is true: [lua( if (Variable["Test"]==true) then "Yes" else "Nope" end )]
I've also tried putting it on the Script's box, using the result to set a text variable, also with no success.
Is my lua syntax wrong?
Last edited by
jordyadan on Mon Jul 16, 2018 12:04 pm, edited 1 time in total.
Tony Li
Posts: 22058 Joined: Thu Jul 18, 2013 1:27 pm
Post
by Tony Li » Fri Jul 13, 2018 3:16 pm
Hi,
Internally, the [lua] tag puts the "return" keyword in front of your expression. The result is that this doesn't make sense to it:
Code: Select all
return if (Variable["Test"]==true) then "Yes" else "Nope" end
The solution is to use this syntax instead:
(
condition ) and (
true-value ) or (
false-value )
Like this:
Code: Select all
Test is true: [lua( (Variable["Test"]==true) and "Yes" or "Nope" )]
jordyadan
Posts: 2 Joined: Fri Jul 13, 2018 1:11 pm
Post
by jordyadan » Mon Jul 16, 2018 12:04 pm
Got it to work, Tony Li, thank you!