-
February 14th, 2021, 03:44 #1
Getting a node from node and string path
Is there a better way to do what I am doing below?
Basically "getAttributePath()" simply takes an attribute ID like str, con, dex etc and puts together a string offset to the char node to point to the score. It already existed for a different need elsewhere and I decided to reuse my creation. Then I saw what I ended up with and it works - but looks clunky.
The getAttributePath gives me a string, I use databasenjode's getPath() which takes a node (nodeChar passed in) and an optional offset (the value I get from getAttrib...) BUT that returns a string not a node. So I then need to do findNode() to get back to node.
Is there another method that if given a node and a "path" that can concat and return the note referring to it?
Like a databasenjode.getNode(baseNod, sOffsetPathFromBaseNode)?
Code:function getAttributePath(sAttributeCode) return "clilist1." .. sAttributeCode .. ".p1" end ... function recalculateAttributeModifiers(nodeChar) local sAttributePath = getAttributePath( Interface.getString("attributes_strength_id")) Character_SWWB.onAttributeScoreChanged(DB.findNode( nodeChar.getPath(sAttributePath))) sAttributePath = getAttributePath( Interface.getString("attributes_intelligence_id")) Character_SWWB.onAttributeScoreChanged(DB.findNode( nodeChar.getPath(sAttributePath))) ... the other 4 attributes...
-
February 14th, 2021, 09:46 #2Private 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 15th, 2021, 06:36 #3
GetChild - dunno what was thinking when went to darabasenode info page that night. Was looking for something with “node” in name but I DID remember there was another way cos thought I’d used it but I searched in code, again on “node” ... was a busy return from that
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks