Behavior Designer - Is Lua True

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
halbey
Posts: 6
Joined: Tue Dec 03, 2019 5:56 pm

Behavior Designer - Is Lua True

Post by halbey »

Hello,

I am trying to build a behavior tree with an "Attack" which is conditional on "Is Lua True". I cannot find the right syntax to check the Lua variable.

I want the AI to attack only if the Lua variable (bool) is true.

E.g. the Lua variable => "player_alive" = true (default as set in the Dialogue Database / Variables)

How should I write the Lua Code in the Behavior Tree? I tried with "player_alive" or "Variable["player_s5duel"]", but it doesn't work.

I have attached the Lua bridge to the AI character

Thank you!
User avatar
Tony Li
Posts: 22149
Joined: Thu Jul 18, 2013 1:27 pm

Re: Behavior Designer - Is Lua True

Post by Tony Li »

Hi,

You shouldn't need the bridge for Is Lua True.

The syntax to check if the Dialogue System variable "player_alive" is true is:

Code: Select all

Variable["player_alive"] == true
halbey
Posts: 6
Joined: Tue Dec 03, 2019 5:56 pm

Re: Behavior Designer - Is Lua True

Post by halbey »

Hi Tony,

thank you for your reply. I tried using this syntax

Code: Select all

Variable["player_alive"] == true
in the Inspector / Lua Code section of the Behavior Designer Tree (see attached), but I get that the "Lua code is null or empty".

Could you confirm that my approach is correct?

1- I start with the variable "player_alive" = true (setup in the Dialogue database)
-> the AI should attack
2- if, conditional to some action, I set the variable to false in a script: DialogueLua.SetVariable("player_alive", false);
-> the AI should not attack
Attachments
BD1.PNG
BD1.PNG (41.78 KiB) Viewed 347 times
User avatar
Tony Li
Posts: 22149
Joined: Thu Jul 18, 2013 1:27 pm

Re: Behavior Designer - Is Lua True

Post by Tony Li »

Hmm, that error is strange, since I see that the Lua Code field has code. From everything you described, you're doing it correctly. Is the error maybe coming from a different behavior tree or a different task node?
Can you send a reproduction project to tony (at) pixelcrushers.com?
halbey
Posts: 6
Joined: Tue Dec 03, 2019 5:56 pm

Re: Behavior Designer - Is Lua True

Post by halbey »

Hi Tony,

I tried again and now it works. The only difference is that I wrote the code instead of just copy pasting...it doesnt make much sense but at least it looks fine

Thank you for your support!
User avatar
Tony Li
Posts: 22149
Joined: Thu Jul 18, 2013 1:27 pm

Re: Behavior Designer - Is Lua True

Post by Tony Li »

Very strange! Glad it's working now.
Post Reply