PDA

View Full Version : Module merge with Campaign database?



VenomousFiligree
September 26th, 2014, 17:42
Can a module be merged with a campaign database? ie all the module data is inserted into the campaign database, rather than being loaded in within FG.

Trenloe
September 26th, 2014, 19:30
Not exactly as you say - the data isn't merged so that code that accesses the base campaign database will automatically include the module. But, what are you trying to do? You can add additional code to step through modules to find other info. For example, I wrote the following code for the Language Chat extension that searches the campaign database and the database in all open modules, it is called with findLanguage(<language name>):


function findLanguageInDB(nodeRoot, sLanguage)
for _,v in pairs(DB.getChildren(nodeRoot, "language_extension")) do
if StringManager.trim(DB.getValue(v, "languagename", "")) == sLanguage then
return v;
end
end

return nil;
end
function findLanguage(sLanguage)
-- Initiates a search for the language name, first in the campaign database and then in the database of modules.

local sFind = string.lower(StringManager.trim(sLanguage));

local nodeLanguage = findLanguageInDB(DB.getRoot(), sFind);
if not nodeLanguage then
local aModules = Module.getModules();
for _,v in ipairs(aModules) do
nodeLanguage = findLanguageInDB(DB.getRoot(v), sFind);
if nodeLanguage then
break;
end
end
end
--Debug.console("language found = " .. nodeLanguage.getNodeName());

return nodeLanguage;
end
The code basically steps through the campaign DB first, looking for a specific language name in the database. Then it goes to each open module in turn, gets the database root of that module and looks for a specific language name in that database.

VenomousFiligree
September 26th, 2014, 22:56
I want to insert the contents of a module into db.xml. I guess i can do it manually, just wanted to know if their was some form of import utility.

Trenloe
September 26th, 2014, 23:01
I want to insert the contents of a module into db.xml. I guess i can do it manually, just wanted to know if their was some form of import utility.
Other than importing characters, there's not a specific import utility. If it's a one off thing, just do it manually...