Script firing twice on bark
Posted: Sun Mar 26, 2017 10:53 am
I'm running into a problem when I'm trying to execute scripts that I registered via Lua.RegisterFunction whenever I try to call them from a bark. Any script that I try to call this way consistently gets fired twice. If I call it from a normal conversation or via the Lua debug console it runs just fine, but no matter the script I'm trying to run, it doubles up on a bark.
Code example: When I try to add this test function (same behavior with this and the real thing I'm trying to run):
then add Test() to the scripts field in a dialogue entry and activate the bark either via a Behavior Designer task or just via raw code like this (to exclude if it might be the BD task messing up):
I get these two debug results at the same time:
The difference between the two seems to be that one of them includes the line "PixelCrushers.DialogueSystem.ConversationModel:GetState(DialogueEntry, Boolean, Boolean, Boolean)", but I've no clue whether this is due to something I messed up or if it's a bug. Any ideas?
Code example: When I try to add this test function (same behavior with this and the real thing I'm trying to run):
Code: Select all
Lua.RegisterFunction("Test", this, typeof(DialogueVars).GetMethod("Test"));
public void Test()
{
Debug.Log("fired");
}
Code: Select all
if(Input.GetKeyDown(KeyCode.J))
{
DialogueManager.Bark("TestBark", this.transform);
}
Code: Select all
fired
UnityEngine.Debug:Log(Object)
DialogueVars:Test() (at Assets/Scripts/DialogueVars.cs:42)
System.Reflection.MethodBase:Invoke(Object, Object[])
Language.Lua.LuaMethodFunction:InvokeMethod(LuaValue[])
Language.Lua.FunctionCall:Evaluate(LuaValue, LuaTable)
Language.Lua.PrimaryExpr:Evaluate(LuaTable)
Language.Lua.ExprStmt:Execute(LuaTable, Boolean&)
Language.Lua.Chunk:Execute(Boolean&)
Language.Lua.Chunk:Execute()
Language.Lua.LuaInterpreter:Interpreter(String, LuaTable)
PixelCrushers.DialogueSystem.Lua:RunRaw(String, Boolean, Boolean)
PixelCrushers.DialogueSystem.Lua:Run(String, Boolean, Boolean)
PixelCrushers.DialogueSystem.ConversationModel:GetState(DialogueEntry, Boolean, Boolean, Boolean)
PixelCrushers.DialogueSystem.<Bark>c__Iterator5:MoveNext()
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
PixelCrushers.DialogueSystem.DialogueSystemController:Bark(String, Transform, Transform, BarkHistory)
PixelCrushers.DialogueSystem.DialogueSystemController:Bark(String, Transform)
PixelCrushers.DialogueSystem.DialogueManager:Bark(String, Transform)
NPC:Update() (at Assets/Scripts/AI/NPC.cs:89)
Code: Select all
fired
UnityEngine.Debug:Log(Object)
DialogueVars:Test() (at Assets/Scripts/DialogueVars.cs:42)
System.Reflection.MethodBase:Invoke(Object, Object[])
Language.Lua.LuaMethodFunction:InvokeMethod(LuaValue[])
Language.Lua.FunctionCall:Evaluate(LuaValue, LuaTable)
Language.Lua.PrimaryExpr:Evaluate(LuaTable)
Language.Lua.ExprStmt:Execute(LuaTable, Boolean&)
Language.Lua.Chunk:Execute(Boolean&)
Language.Lua.Chunk:Execute()
Language.Lua.LuaInterpreter:Interpreter(String, LuaTable)
PixelCrushers.DialogueSystem.Lua:RunRaw(String, Boolean, Boolean)
PixelCrushers.DialogueSystem.Lua:Run(String, Boolean, Boolean)
PixelCrushers.DialogueSystem.<Bark>c__Iterator5:MoveNext()
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
PixelCrushers.DialogueSystem.DialogueSystemController:Bark(String, Transform, Transform, BarkHistory)
PixelCrushers.DialogueSystem.DialogueSystemController:Bark(String, Transform)
PixelCrushers.DialogueSystem.DialogueManager:Bark(String, Transform)
NPC:Update() (at Assets/Scripts/AI/NPC.cs:89)