DICE PACKS BUNDLE
  1. #1
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075

    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...

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,404
    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!

  3. #3
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075
    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

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