DICE PACKS BUNDLE
  1. #1

    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

  2. #2
    Can you add Debug.chat or Debug.console statements layered between each section to see where the return values diverge in behavior?

    Thanks,
    PG

  3. #3
    pretty sure i've solved my issue so far, it at least appears i have. the DB.getChild(wNode) needed the second parameter in the last section, and i needed to parse and condense the npc name again for the second/middle section.

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
  •  
STAR TREK 2d20

Log in

Log in