Hello
I was using version 1.7.xx and updated to version 2.2.8.
In the course of testing, there were parts that behave differently from previous versions of the code.
When DialogueManager.AddDatabase() is called, DialogueLua.AddChatMapperVariables() is called inside.
Looking at the DialogueLua.AddChatMapperVariables() logic, unlike the previous version, it was overwriting all of the lua tables.
In 1.7.x.x version, only the part included in the newly added database was added to LuaTable.
Is there any reason for this change? I want to know if there is a reason.
Thanks for reading.
I am curious about DialogueManager.AddDatabase().
Re: I am curious about DialogueManager.AddDatabase().
Hi,
This is the code of DatabaseManager.Add(), which is what DialogueManager.AddDatabase() calls:
It will only initialize variables if no other databases have been loaded. If other databases have been loaded, it will not call DialogueLua.InitializeChatMapperVariables().
This is the code of DatabaseManager.Add(), which is what DialogueManager.AddDatabase() calls:
Code: Select all
public void Add(DialogueDatabase database)
{
if ((database != null) && !m_loadedDatabases.Contains(database))
{
if (m_loadedDatabases.Count == 0) DialogueLua.InitializeChatMapperVariables();
m_masterDatabase.Add(database);
DialogueLua.AddChatMapperVariables(m_masterDatabase, m_loadedDatabases);
m_loadedDatabases.Add(database);
}
}
Re: I am curious about DialogueManager.AddDatabase().
Hi Tony.
I'm waiting for your reply
I have a question about AddChatMapperVariables().
Currently in our game, the quest dialog is divided into several DialogueDatabases and managed.
So I use AddDatabase and RemoveDatabase from time to time.
In the process, I found that the values stored as Lua on the Item side were reset. So, while looking for a reason, I became suspicious of AddChatMapperVariables().
When I check AddChatMapperVariables(), it seems to overwrite all existing Lua values. Is that correct? If yes, I wonder why.
If you look at the code, comments are also left.
In the process of doing AddDatabase(), the existing Lua data disappears, and I am having a hard time.
I'm waiting for your reply
I have a question about AddChatMapperVariables().
Code: Select all
public static void AddChatMapperVariables(DialogueDatabase database, List<DialogueDatabase> loadedDatabases)
{
if (database == null) return;
var first = (loadedDatabases == null || loadedDatabases.Count == 0);
AddToTable<Actor>("Actor", database.actors, loadedDatabases, first);
AddToTable<Item>("Item", database.items, loadedDatabases, first);
AddToTable<Location>("Location", database.locations, loadedDatabases, first);
AddToVariableTable(database.variables, loadedDatabases, first);
AddToConversationTable(database.conversations, loadedDatabases, first);
if (!string.IsNullOrEmpty(database.globalUserScript)) Lua.Run(database.globalUserScript, DialogueDebug.LogInfo);
}
So I use AddDatabase and RemoveDatabase from time to time.
In the process, I found that the values stored as Lua on the Item side were reset. So, while looking for a reason, I became suspicious of AddChatMapperVariables().
Code: Select all
private static void AddToTable<T>(string arrayName, List<T> assets, List<DialogueDatabase> loadedDatabases, bool addRaw) where T : Asset
{
// Note: Optimized: Overwrite existing values.
Lua.WasInvoked = true;
LuaTable assetTable = Lua.Environment.GetValue(arrayName) as LuaTable;
if (assetTable == null) return;
for (int i = 0; i < assets.Count; i++)
{
var asset = assets[i];
var assetIndex = StringToTableIndex(asset.Name);
LuaTable fieldTable = new LuaTable();
for (int j = 0; j < asset.fields.Count; j++)
{
var field = asset.fields[j];
var fieldIndex = StringToTableIndex(field.title);
fieldTable.AddRaw(fieldIndex, GetFieldLuaValue(field));
}
if (addRaw)
{
assetTable.AddRaw(assetIndex, fieldTable);
}
else
{
assetTable.SetKeyValue(new LuaString(assetIndex), fieldTable);
}
}
}
If you look at the code, comments are also left.
In the process of doing AddDatabase(), the existing Lua data disappears, and I am having a hard time.
Re: I am curious about DialogueManager.AddDatabase().
Hi,
That optimization was removed in version 2.2.9. Here's a patch for 2.2.8:
DS_2_2_8_DialogueLuaPatch_2020-08-10.unitypackage
(Edit: I previously linked an older version of this patch. This is the latest version.)
Now when you add a database that contains values that already exist in the Dialogue Manager's master database, the added database does not overwrite the already-existing values of actors, items/quests, locations, or variables in the master database.
That optimization was removed in version 2.2.9. Here's a patch for 2.2.8:
DS_2_2_8_DialogueLuaPatch_2020-08-10.unitypackage
(Edit: I previously linked an older version of this patch. This is the latest version.)
Now when you add a database that contains values that already exist in the Dialogue Manager's master database, the added database does not overwrite the already-existing values of actors, items/quests, locations, or variables in the master database.
Re: I am curious about DialogueManager.AddDatabase().
Hello Tony
Thanks for the answer.
To start with the conclusion, I got the patch and the problem was fixed
To give you some feedback,
1. The patch contents were not applied to version 2.2.9.
2. In the GetExistingAssetNames() method,
I got a null exception, so I fixed it like this:
HashSet<string> existingAssetNames = new HashSet<string>();
Thank you.
Thanks for the answer.
To start with the conclusion, I got the patch and the problem was fixed
To give you some feedback,
1. The patch contents were not applied to version 2.2.9.
2. In the GetExistingAssetNames() method,
I got a null exception, so I fixed it like this:
HashSet<string> existingAssetNames = new HashSet<string>();
Thank you.
Re: I am curious about DialogueManager.AddDatabase().
Thanks. The patch is updated now. Strange about the Asset Store. It should still say 2.2.8 because 2.2.9. is pending review. But the correct 2.2.9 should be available tomorrow on the store.