Varsuuk
February 14th, 2021, 03:44
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)?
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...
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)?
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...