Page 1 of 1

'setProp' function from articy working unexpectedly

Posted: Sat Nov 10, 2018 5:32 pm
by _marc
Hi,

I am using the "setProp" function from articy, in the output pin of a node, to set a boolean actor field from false to true :

setProp(getObj("MyCharacter"), "IsInPrison", true)

To track this variable in Unity I have added a LuaObserver on it (running on every update). But when the node is played at runtime, the LuaObserver doesn't "catch" the change. After a lot of attempts, I have noticed a strange thing while debugging these two lines at the same time:

Debug.Log (DialogueLua.GetActorField("MyCharacter", "IsInPrison").AsBool);
Debug.Log (DialogueManager.masterDatabase.GetActor("MyCharacter").AssignedField("IsInPrison").value);

-> false
-> true


Is it normal? Shouldn't the setProp function and the DialogueLua.SetActorField function do exactly the same thing?

Thanks for your help :)

Marc

Re: 'setProp' function from articy working unexpectedly

Posted: Sat Nov 10, 2018 7:53 pm
by Tony Li
Hi Marc,

At runtime, the content of the dialogue database is loaded into a Lua virtual machine. Dialogue database values don't change at runtime, but Lua values do.

At runtime, you can read dialogue database values using DialogueManager.masterDatabase.GetXXX().etc.. These values are static and don't change.

At runtime, you can read and write Lua values using the DialogueLua class. Functions like setProp() change Lua values.

I would expect the output of those two lines to be the opposite, where DialogueLua.GetActorField() returns true, and masterDatabase.GetActor().etc.. returns false. Did you add an Articy Lua Functions component to your Dialogue Manager to make setProp() available?

BTW, when debugging, you can also run Lua functions manually using the Lua Console or the Dialogue Editor window's Watches tab.

Re: 'setProp' function from articy working unexpectedly

Posted: Sun Nov 11, 2018 9:28 am
by _marc
Hi,

In this case, it seems that the 'setProp' function modifies the master database and not the Lua value. Is it possible?
I have added some debug lines to the ArticyLuaFunction script, in the setProp() function, to be able to check the variable value before/after setProp, in the master database and in the Lua table:

if (objectIdentifier.StartsWith("Actor_"))
{
Debug.Log("Object Identifier is: " + objectIdentifier + " - Property name is: " + propertyName + " - value is:" + value);

Debug.Log("Value in db before setProp: " + db.GetActor("Ama").AssignedField("IsInPrison").value);
Debug.Log("Value in Lua table before setProp: " + DialogueLua.GetActorField("Ama", "IsInPrison").AsBool);
SetAssetFieldValue(db.GetActor(id), propertyName, value);
Debug.Log("Value in db after setProp: " + db.GetActor("Ama").AssignedField("IsInPrison").value);
Debug.Log("Value in Lua table after setProp: " + DialogueLua.GetActorField("Ama", "IsInPrison").AsBool);
}


Debug results at runtime:

Object Identifier is: Actor_1 - Property name is: IsInPrison - value is:True -> ok
Value in db before setProp: False -> ok, this is the default value
Value in Lua table before setProp: False -> ok
Value in db after setProp: True -> should be false
Value in Lua table after setProp: False -> should be true, now

The debug lines confirm that the setProp articy function is read and sent to the C# setProp function in ArticyLuaFunction.cs. So far, so good. But I can't understand why the 4th debug line is set to True, and why the 5th debug line is still false. Debugging with Dialogue Editor Watches and Lua console give the same result: Lua value doesn't change.

Re: 'setProp' function from articy working unexpectedly

Posted: Sun Nov 11, 2018 12:29 pm
by _marc
I've tested in a new fresh scene, with a new articy document (from the Dialogue System template): the same things happen: after setting an actor field(boolean) to true with "setProp", the Lua command return Variable["ActorName"].FieldName still returns false. But if I run "getProp" after that, in a condition node as an example, the value is true. I can send you the scene if you want.

Re: 'setProp' function from articy working unexpectedly

Posted: Sun Nov 11, 2018 1:41 pm
by Tony Li
This is indeed a bug. I'll post the fix here soon.

Re: 'setProp' function from articy working unexpectedly

Posted: Sun Nov 11, 2018 2:19 pm
by Tony Li
I'm really sorry about that bug. If you import this package, it should fix it:

DS2_ArticyLuaFunctions_Patch2018-11-11.unitypackage

Re: 'setProp' function from articy working unexpectedly

Posted: Sun Nov 11, 2018 4:15 pm
by _marc
This is a lot better ;) Now the LuaObserver works correctly, as well... Thank you for the quick fix!

Re: 'setProp' function from articy working unexpectedly

Posted: Sun Nov 11, 2018 4:35 pm
by Tony Li
Glad to help!