getChild() Classic vs Unity trouble
hey guys. working on some code, i'm struggling in classic where i'm not in unity for some reason. i've got a window with a few lists to accommodate the lists of an npc (traits, actions, reactions etc) and while the code works fine in unity, classic is failing to do the same. the issue appears to be something to do with getChild(), i either get an invalid argument, or what it's returning isn't being applied to the setDatabaseNode() functions further down. here's a bit that's exhibiting this behavior.
Code:
if DataSourceCheck == 0 then
ModuleSource = "";
end
local NPCnameCondensed = "";
local NPCname = string.lower(getValue());
local NPCnameTable = StringManager.parseWords(NPCname);
for k,v in pairs(NPCnameTable) do
NPCnameCondensed = NPCnameCondensed .. v;
end
local sourceName = "actions";
local sourceNameTraits = "traits";
local sourceNameReactions = "reactions";
local sourceNameLegendaryActions = "legendaryactions";
local sourceNameLairActions = "lairactions";
local sourceNameInnateSpells = "innatespells";
local newDatatext = NPCMergerManager.setListNode(NPCnameCondensed, sourceName, ModuleSource);
local newDataSource = { databasenode = { "" .. NPCMergerManager.setListNode(NPCnameCondensed, sourceName, ModuleSource) .."" },};
local newDataSourceTraits = { databasenode = { "" .. NPCMergerManager.setListNode(NPCnameCondensed, sourceNameTraits, ModuleSource) .."" },};
local newDataSourceReactions = { databasenode = { "" .. NPCMergerManager.setListNode(NPCnameCondensed, sourceNameReactions, ModuleSource) .."" },};
local newDataSourceLegendaryActions = { databasenode = { "" .. NPCMergerManager.setListNode(NPCnameCondensed, sourceNameLegendaryActions, ModuleSource) .."" },};
local newDataSourceLairActions = { databasenode = { "" .. NPCMergerManager.setListNode(NPCnameCondensed, sourceNameLairActions, ModuleSource) .."" },};
local newDataSourceInnateSpells = { databasenode = { "" .. NPCMergerManager.setListNode(NPCnameCondensed, sourceNameInnateSpells, ModuleSource) .."" },};
if DataSourceCheck == 0 then
local DBNPCs = DB.getChildren("npc");
for k,v in pairs(DBNPCs) do
local aChild = DB.getChild("npc", k);
if aChild then
kDatabaseNode = aChild;
kDatabaseText = string.lower(DB.getValue(kDatabaseNode, "name", ""));
if kDatabaseText == NPCnameCondensed then
-------------------------------------------------------problem is somewhere around here it seems? ------------------------------
Debug.console("kDatabaseNode, NPCnameCondensed =", kDatabaseNode, NPCnameCondensed);
newDataSource = { databasenode = { kDatabaseNode }, };
local getTraits = DB.getChild(kDatabaseNode, "traits")
local getActions = DB.getChild(kDatabaseNode, "actions")
local getReActions = DB.getChild(kDatabaseNode, "reactions")
local getLegendaryActions = DB.getChild(kDatabaseNode, "legendaryactions")
local getLairActions = DB.getChild(kDatabaseNode, "lairactions")
local getInnateSpells = DB.getChild(kDatabaseNode, "innatespells")
window.actions.setDatabaseNode(getActions);
window.traits.setDatabaseNode(getTraits);
window.reactions.setDatabaseNode(getReActions);
window.legendaryactions.setDatabaseNode(getLegendaryActions);
window.lairactions.setDatabaseNode(getLairActions);
window.innatespells.setDatabaseNode(getInnateSpells);
else
window.traits.setDatabaseNode("npcmerger.traitslist");
window.actions.setDatabaseNode("npcmerger.actionlist");
window.reactions.setDatabaseNode("npcmerger.reactionlist");
window.legendaryactions.setDatabaseNode("npcmerger.legendaryactionlist");
window.lairactions.setDatabaseNode("npcmerger.lairactionlist");
window.innatespells.setDatabaseNode("npcmerger.innatespellslist");
end
end
end
end
if DataSourceCheck > 0 then
for k,v in pairs(newDataSource) do
for k,w in pairs(v) do
local wNode = w;
local wChild = DB.getChild(wNode);
Debug.console("actions check, wChild", k, w, wChild);
if wChild then
window.actions.setDatabaseNode(w);
else
if k ~= 0 then
window.actions.setDatabaseNode("npcmerger.actionlist");
end
end
end
end