Update database node types of modules works only with reload command?
Hello,
I am working on a new version of the dark eye ruleset. Because of some changes in the item area I added a script in the VersionManager which should update the datatype.
For some reason the code does not seem to run when starting a campaign with the module loaded. It only seems to run after typing /reload in the chat window.
Console Message:
Code:
[29.12.2017 11:18:10] Runtime Notice: s'scripts/manager_debug.lua, setLogLevel, Auswahl:' | s'0'
[29.12.2017 11:18:10] Runtime Notice: s'scripts/manager_version.lua, updateDatabase, minor: ' | #3
[29.12.2017 11:18:10] Runtime Notice: s'scripts/manager_version.lua, updateDatabase, major: ' | #6
[29.12.2017 11:18:21] Ruleset Error: windowcontrol: Database type mismatch for control (nonidentified) in windowclass (item_description)
[29.12.2017 11:18:21] Ruleset Error: windowcontrol: Database type mismatch for control (nonidentified_player) in windowclass (item_description)
Code fragment of VersionManager:
Code:
function onInit()
DebugM.printLogMessage("scripts/manager_version.lua, onInit");
if User.isHost() then
updateDatabase(DB.findNode("."));
end
OOBManager.registerOOBMsgHandler("OOB_lCA", onOOBlCANachricht); --Aufruf bei lokaler Charakterauswahl
DebugM.printLogMessage("scripts/manager_version.lua, onInit, Ende");
end
function updateDatabase(nodeRoot)
DebugM.printLogMessage("scripts/manager_version.lua, updateDatabase");
if not nodeRoot then
return;
end
local major, minor = nodeRoot.getRulesetVersion();
Debug.console("scripts/manager_version.lua, updateDatabase, minor: ", minor);
Debug.console("scripts/manager_version.lua, updateDatabase, major: ", major);
-- Florindel, To-Do: entfernen nachdem Tests abgeschlossen sind
updateItems();
[...]
end
function updateItems()
DebugM.printLogMessage("scripts/manager_version.lua, updateItems");
-- Florindel, läuft nur bei jedem zweiten Mal durch die Module??
local nodeItem = DB.findNode("item");
Debug.console("versionmanager, updateItems, nodeItem: ", nodeItem);
if nodeItem then
for _, v in pairs(DB.getChildrenGlobal(nodeItem)) do
Debug.console("versionmanager, updateItems, v: ", v);
local nodeNonId = v.getChild("nonidentified");
Debug.console("versionmanager, updateItems, nodeNonId: ", nodeNonId);
if nodeNonId and nodeNonId.getType() ~= "formattedtext" then
local sText = nodeNonId.getValue();
nodeNonId.delete();
DB.setValue( v, "nonidentified", "formattedtext", sText );
end
[...]
end
end
end
After entering /reload the console contains this:
Code:
[29.12.2017 11:24:25] Runtime Notice: s'scripts/manager_version.lua, updateDatabase, minor: ' | #3
[29.12.2017 11:24:25] Runtime Notice: s'scripts/manager_version.lua, updateDatabase, major: ' | #6
[29.12.2017 11:24:25] Runtime Notice: s'versionmanager, updateItems, nodeItem: ' | databasenode = { item }
[29.12.2017 11:24:25] Runtime Notice: s'versionmanager, updateItems, v: ' | databasenode = { item.id-00001@DSA Atlas }
[29.12.2017 11:24:25] Runtime Notice: s'versionmanager, updateItems, nodeNonId: ' | databasenode = { item.id-00001.nonidentified@DSA Atlas }
[29.12.2017 11:24:25] Runtime Notice: s'versionmanager, updateItems, v: ' | databasenode = { item.id-00002@DSA Atlas }
[29.12.2017 11:24:25] Runtime Notice: s'versionmanager, updateItems, nodeNonId: ' | databasenode = { item.id-00002.nonidentified@DSA Atlas }
I expected that the code would run even when loading the campaign for the first time.
Regards,
Jens