I am using the buttongroup_counter template on the main desktop.
It looks great, and loads correct. The problem is, in the onInit, there is this section:
When I run the code, nodeWin comes up as nil for both player and host. How can I call this so that it will work for everyone?Code:-- Synch to the data nodes
local nodeWin = window.getDatabaseNode();
if nodeWin then
local sLoadMaxNodeName = "";
local sLoadCurrNodeName = "";
if sourcefields then
if sourcefields[1].maximum then
sLoadMaxNodeName = sourcefields[1].maximum[1];
end
if sourcefields[1].current then
sLoadCurrNodeName = sourcefields[1].current[1];
end
end
if sLoadMaxNodeName ~= "" then
if not DB.getValue(nodeWin, sLoadMaxNodeName) then
DB.setValue(nodeWin, sLoadMaxNodeName, "number", 1);
end
setMaxNode(DB.getPath(nodeWin, sLoadMaxNodeName));
end
if sLoadCurrNodeName ~= "" then
setCurrNode(DB.getPath(nodeWin, sLoadCurrNodeName));
end
end
I was thinking of throwing that section into a separate function, and when host call it at one point, and when player, call it when char sheet opens. If I do that, I feel like I may need to create a different nodeWin for player and host, but I'm not sure if this will work or not. I don't know if it will be as simple as that, since the file also has a few other functions that will do a DB.getValue and DB.setValue. Any insight would be appreciated.