View Full Version : Issue with getting Value from a node in DB
kalannar
May 30th, 2023, 20:01
I am trying to retrieve a value from a node in the DB. I hard coded the strings to try and figure out why I am not getting the value.
function CharacteristicRoll(rSource, rTarget, rRoll)
local Target = DB.getValue("charsheet.id-00001", "wsCurrent", 0);
Debug.chat(Target);
end
Target comes out as "wsCurrent" instead of the number value. Any ideas what I am missing?
Trenloe
May 30th, 2023, 20:18
You can only specify a child if the source is a database node object, not a string. As you're using a string, the second argument is the default value to return.
See here: https://fantasygroundsunity.atlassian.net/wiki/spaces/FGCP/pages/996644582/DB#getValue
kalannar
May 30th, 2023, 20:44
how do you get the database node object in a script? I know of window.getDatabaseNode(). But it doesn't work in the action script. I have the type from rSource.
Trenloe
May 30th, 2023, 20:55
DB.findNode can be used to get the node from a string node name: https://fantasygroundsunity.atlassian.net/wiki/spaces/FGCP/pages/996644582/DB#findNode
However, you can concatenate "charsheet.id-00001" and "wsCurrent" into a single DB path: "charsheet.id-00001" .. "." .. "wsCurrent" then use DB.getValue on the complete path.
See here for information on database paths: https://fantasygroundsunity.atlassian.net/wiki/spaces/FGCP/pages/996644468/Ruleset+-+Database#Database-Paths
Try this:
local Target = DB.getValue("charsheet.id-00001" .. "." .. "wsCurrent", 0);
Powered by vBulletin® Version 4.2.1 Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.