Using condition in dialogue text
Posted: Sat Jul 09, 2022 5:50 am
Hello, can you help me?
I want to use "if .. then" statement in nodes
For example I have variable "number_of_pirates" and I want to change NPS replica depending on it
And I have this lua code
In theory this code must generate phrase like: "there are 2 more pirates left"
I wrote it in one line
But I get nil instead.
And no errors or warnings in console
P.S.
I know that I can use 2 nodes with appropriate conditions instead, but what if it will be more complicated logic?
I want to use "if .. then" statement in nodes
For example I have variable "number_of_pirates" and I want to change NPS replica depending on it
And I have this lua code
Code: Select all
[lua(
if (Variable["number_of_pirates"] > 1)
then
"there are " .. Variable["number_of_pirates"] .. " more pirates left"
else
"there is one more pirate left"
end
)]
I wrote it in one line
But I get nil instead.
And no errors or warnings in console
P.S.
I know that I can use 2 nodes with appropriate conditions instead, but what if it will be more complicated logic?