Page 1 of 1

Script firing twice on bark

Posted: Sun Mar 26, 2017 10:53 am
by Enphra
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):

Code: Select all

Lua.RegisterFunction("Test", this, typeof(DialogueVars).GetMethod("Test"));

public void Test()
	{
		Debug.Log("fired");
	}
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):

Code: Select all

if(Input.GetKeyDown(KeyCode.J))
		{
			DialogueManager.Bark("TestBark", this.transform);
		}
I get these two debug results at the same time:

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)
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?

Re: Script firing twice on bark

Posted: Sun Mar 26, 2017 12:15 pm
by Tony Li
It's a bug, fixed in the upcoming version 1.6.9. I plan to submit version 1.6.9 to the Unity Asset Store early this week. It'll also be available on the Pixel Crushers customer download site. If you'd like access to the site, please PM me your Unity Asset Store invoice number.

Re: Script firing twice on bark

Posted: Sun Mar 26, 2017 12:44 pm
by Enphra
Ah nice, good to hear there'll be a fix, thanks for the quick reply.

Re: Script firing twice on bark

Posted: Wed Mar 29, 2017 8:57 pm
by Tony Li
Thanks again for letting me know about this bug. It's fixed in version 1.6.9, which is available now on the Pixel Crushers customer download site.