Page 1 of 1

[Solved] If statemens on Dialogue Entries

Posted: Fri Jul 13, 2018 1:36 pm
by jordyadan
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?

Re: If statemens on Dialogue Entries

Posted: Fri Jul 13, 2018 3:16 pm
by Tony Li
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" )]

Re: If statemens on Dialogue Entries

Posted: Mon Jul 16, 2018 12:04 pm
by jordyadan
Got it to work, Tony Li, thank you!

Re: [Solved] If statemens on Dialogue Entries

Posted: Mon Jul 16, 2018 1:45 pm
by Tony Li
Happy to help!