Thread: DB path of a known name
-
February 5th, 2023, 20:01 #1
-
February 5th, 2023, 20:33 #2
This is my solution. There is a better way?
Code:function getGlobalElementPath(sElementName, sSource) if sElementName == "" or sSource == "" then return nil; end for _, nodeElement in pairs(DB.getChildrenGlobal(sSource)) do if nodeElement.getChild("name").getValue() == sElementName then return nodeElement; end end end
-
February 5th, 2023, 20:40 #3
That's what you have to do - iterate through the node hierarchy.
I'd recommend you change nodeElement.getChild("name").getValue() to DB.getValue(nodeElement, "name", "") this is more efficient (less API calls) and it also returns a default of "" if the node doesn't exist - which will help to avoid errors if it doesn't exist.Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
February 5th, 2023, 20:41 #4
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks