PDA

View Full Version : DB.getValue



Varsuuk
January 6th, 2021, 05:06
[EDIT - ignore title, someone moved posts around - the title refers to a previously posted and solved thread which still exists with same name below... ;)]


The following is from MoreCore:manager_char_mc.lua



function addClassLevel(nodeChar, sClass, sRecord, nLevel)
local nodeSource = resolveRefNode(sRecord);

Debug.console("nodeChar: ", nodeChar);
Debug.console("sClass: ", sClass);
Debug.console("sRecord: ", sRecord);
local nLevel = DB.getValue(nodeChar, "pcclasslevel", "number");
...


Is the code doing what I think it is doing? i.e., if nodeChar.pcclasslevel does not exist, the value "number" is returned (which is a string instead of the number type expected)?

If I read it right (rusty and wasn't ever a pro), it probably should be:
local nLevel = DB.getValue(nodeChar, "pcclasslevel", 0);

damned
January 6th, 2021, 12:54
You are probably right.

Varsuuk
January 6th, 2021, 22:28
In this case, it isn't likely to be able to cause a problem since, if I recall, pcclasslevel is a control and therefore already exists so the "default" part of that will never trigger.

This was just me noticing the mismatch and commenting for an "as-u-go" fix if I was correct.
Damned - what's best way to report anything if see something? Discord message, post here in Workshop, or post in OtherRulesets/MoreCore? (I was going to post in the last one but thought since was code maybe here?)