If I try to do something like
Code: Select all
DialogueLua.SetConversationField(DialogueManager.Instance.lastConversationID, "IsStarted", true);
Code: Select all
DialogueLua.SetConversationField(DialogueManager.Instance.lastConversationID, "IsStarted").asBool;
I used to use an older version of the DialogueSystem for which I wrote this method myself (it didn't exist yet back then) and this one works, it is also more alike the other SetItemField and SetActorField methods.
Code: Select all
public static void SetConversationField(int conversationId, string field, object value)
{
if (Lua.Environment.GetValue("Conversation") is not LuaTable luaTable)
throw new System.NullReferenceException("Conversation table not found in Lua environment.");
if (luaTable.GetValue(conversationId) is not LuaTable elementTable)
Debug.LogError($"Failed to find conversation {conversationId} to set field {field} to {value}.");
else
{
Lua.WasInvoked = true;
elementTable.SetNameValue(StringToTableIndex(field), LuaInterpreterExtensions.ObjectToLuaValue(value));
}
}