DICE PACKS BUNDLE
  1. #1

    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

  2. #2
    Already found a solution:
    1. I removed
    Code:
            local nodeItem = DB.findNode("item");
    	Debug.console("versionmanager, updateItems, nodeItem: ", nodeItem);
    	if nodeItem then
    and changed
    for _, v in pairs(DB.getChildrenGlobal(nodeItem)) do
    into
    for _, v in pairs(DB.getChildrenGlobal("item")) do

    2. in module_selectionentry.lua I added VersionManager.updateItems(); to the function activate() so that the code is also triggered when activating a module during play.

    Are there any suggestions to improve it even further?

  3. #3
    I would use the examples in the 3.5E ruleset version manager code, since there have been many database migrations in that ruleset over the years.

    Regards,
    JPG

  4. #4
    Thanks a lot, Jpg. I will take a look at it.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Character Create Playlist

Log in

Log in