Hi,
I'm out of the office right now, but when I get back I can post a Lua function that should be able to take care of that.
However, running Lua code every Update may be a little excessive. Checking every Update is called
polling. Often,
event-driven checking can be more efficient since it only checks when you actually change a field. Do you have control over how Location fields get changed? For example, do you change it in your code or conversations, like:
Code: Select all
Lua.Run("Location['Person'].MC = true");
Or a similar line in a dialogue entry's
Script field?
If so, you could add a C# method named SetLocationField(), like this:
Code: Select all
public void SetLocationField(string locationName, string fieldName, object value) {
DialogueLua.SetLocationField(locationName, fieldName, value);
OnLocationFieldChanged(locationName, fieldName);
}
void OnLocationFieldChanged(string locationName, string fieldName) {
Debug.Log("Location " + locationName + " field " + fieldName + " changed!");
}
Then instead of:
Code: Select all
Lua.Run("Location['Person'].MC = true");
You could use this:
Code: Select all
SetLocationField("Person", "MC", true);
Would that work better for you, or would you like a Lua function to help check every Update?