Behavior Tree Lua Bridge

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Ooghe
Posts: 8
Joined: Mon Oct 06, 2014 12:19 pm

Behavior Tree Lua Bridge

Post by Ooghe »

I’ve successfully set up Third Party Support for Behavior Tree, and I’ve just been testing it out. The Behavior Designer Sequencer Commands work, but I’m having trouble working with the Behavior Tree Lua Bridge.



I have a shared bool in my Behavior Designer tree called “PurpleFactor”, which I’m hoping to access in lua. The behavior tree is on game object “Character 5”, which, when it encounters the Player, starts a conversation in Dialogue Manager.



The Character 5 game object, in addition to having the Behavior tree script, now has the Lua Bridge script on it as well. My understanding is that that script should create variable “Character_5_PurpleFactor” in Dialogue Manager.



Testing through the lua console returns ‘nil’ however, and I also tried manually calling SyncToLua() in both BD and DS, but that throws this console error:

Dialogue System: Lua code 'SyncToLua()' threw exception 'Invoke function call on non function value.'



which, I suppose means there’s no such function, and makes me wonder if there’s an error in that script. It’s possible, though, that I’ve somehow set up the DialogueDatabase wrong, although whether ‘Sync Variables’ is checked or unchecked doesn’t affect the outcome.



Does anyone have any ideas what could be happening? Do I need to create a variable in my database for this to work?
User avatar
Tony Li
Posts: 20769
Joined: Thu Jul 18, 2013 1:27 pm

Behavior Tree Lua Bridge

Post by Tony Li »

Hi Robert,



SyncToLua() is a method in BehaviorTreeLuaBridge. You can call it on Character 5 like this:

GameObject.Find("Character 5").SendMessage("SyncToLua");

However, the sync should work without this. Please feel free to email me an example project that has the issue.



If you want to test another way, load the Dialogue System sample scene provided by Opsive. (It's the 2D scene where the red guy offers to shoot the alien.) Add a BehaviorTreeLuaBridge to "npc". Add a LuaConsole to the Dialogue Manager.



Then play the scene. After the conversation starts, bring up the console. There should be a Lua value for Variable[npc_Speed].



One more thing: Only bools, floats, ints, and strings are synced. Lua doesn't have, for instance, a concept of UnityEngine.Color.
Ooghe
Posts: 8
Joined: Mon Oct 06, 2014 12:19 pm

Behavior Tree Lua Bridge

Post by Ooghe »

Interestingly, I am getting the same error with the Opsive example scene- the console just outputs "no return value" for npc_Speed...
User avatar
Tony Li
Posts: 20769
Joined: Thu Jul 18, 2013 1:27 pm

Behavior Tree Lua Bridge

Post by Tony Li »

Robert,



Thanks for sending the file and detailed description in email. I'll continue working with you through email and post the resolution here at the end.
Post Reply