PDA

View Full Version : DB.getValue(4 args?)



Varsuuk
May 22nd, 2018, 02:09
I am going through functionality in 5e's CharManager for my own use.

I see there is a call to:
local _,sExistingClassPath = DB.getValue(v, "shortcut", "", "");

in the addClassRef function.

The API page only lists a 3 argument version of DB.getValue() is there another I didn't find or did they add another option or is it a typo that is ignored due to how lua works (yes, real book months ago, forgot most already - it's just a jumble of languages in my head...)

Varsuuk
May 22nd, 2018, 02:15
Also, while at it:

local _,sExistingClassPath = DB.getValue(v, "shortcut", "", "");

I do not see any "shortcut" member in the 5e (SRD) xml, is this anything that exists or a leftover from a bygone era?

Trenloe
May 22nd, 2018, 02:18
Looking at the API doc a little closer...


The return value(s) vary depending on the type of the node.


default (...) [optional]
The value(s) to be returned if getValue fails. (node does not exist; or non-value node)

And note the code that uses this is expecting 2 values to be returned - the first is ignored (the underscore). Hence why there are 2 default values being passed, because getValue on a "shortcut" node returns 2 values.

The "shortcut" node type in the database has 2 child values - <class> and <recordname>. For example:


<shortcut type="windowreference">
<class>referenceskill</class>
<recordname>reference.skills.acrobatics@PFRPG Basic Rules</recordname>
</shortcut>

Trenloe
May 22nd, 2018, 02:20
I do not see any "shortcut" member in the 5e (SRD) xml, is this anything that exists or a leftover from a bygone era?
Create a shortcut in a story entry and then look at the campaign db.xml.

Varsuuk
May 22nd, 2018, 02:28
Thanks Trenloe - was JUST coming here to edit that shortcut one and say I misread as being part of CLASSES in the Mod vs in Campaign.

I am tracing creation and adding by opening campaign, doing stuff closing it - loading xml and following the code. I just misread source vs nodelist classes. Thanks!
DB.getValue(v, "shortcut", "", "");

As for my first question, I meant there are 4 >parameters< in the call to getValue():

where in the DB.getValue API ref, I see only 3:
function getValue( sourcenode, [subpath], [default] )


I'm familiar with "_" concept originally from my Boost days (the ignore var), I think Swift uses "_" as well in similar fashion.

Trenloe
May 22nd, 2018, 02:30
As for my first question, I meant there are 4 >parameters< in the call to getValue():

where in the DB.getValue API ref, I see only 3:
function getValue( sourcenode, [subpath], [default] )
Read post #3 again - especially the default (...) [optional] section.

Varsuuk
May 22nd, 2018, 02:43
GAH! (s) ... right then... carry on :)