PDA

View Full Version : getValue() from DB?



Ranzarok
August 30th, 2019, 23:01
Hey all.

I'm struggling to figure out how to retrieve a value from a basicnumber container to display on a client's desktop panel (window).
I have a windowclass that is opened and controlled by the host. Inside is a basicnumber and a value that I would like to get and display in a label on the client side.


Here is what I have.
https://i.imgur.com/sdnzPgp.png
Host side window(the value I want to retrieve):
windowclass = trackerwindow
databasenode = TrackBox


<basicnumber name="grpdoompool">
<bounds>55,110,20,20</bounds>
<script>
function onDoubleClick(x,y)
local rActor = ActorManager.getActor("pc", window.getDatabaseNode());
Debug.console("rActor: ");
Debug.console(rActor);

local nodeWin = window.getDatabaseNode();
Debug.console("nodeWin: ");
Debug.console(nodeWin);

local doompool = nodeWin.getChild("grpdoompool").getValue();
Debug.console(doompool);

nodeWin.getChild("grpdoompool").setValue(doompool+1);
Debug.console(doompool);

local msg = {font = "msgfont", icon = "adddoomicon"};
msg.text = rActor.sName .. " added 1 to the DM Doom Pool. ";
Comm.deliverChatMessage(msg);
end
</script>
</basicnumber>


Client side window (where I want to display the above value):
https://i.imgur.com/xKx7VcV.png
This is part of a window that gets generated on initialization, part of the desktop_panels. I just want it to report the value, the client does not have to manipulate it whatsoever.
The script here does not work. The console tells me that it's a nil value.


<label name="gmdoompool">
<bounds>55,110,20,20</bounds>
<frame name="fieldlight" offset="5,5,5,5" />
<font>calendarbold</font>
<color>111111</color>
<center />
<script>
function onInit()
DB.addHandler(DB.getPath(TrackBox, "grpdoompool"), "onUpdate", onDoomChanged);
onDoomChanged();
end

function onClose()
DB.removeHandler(DB.getPath(TrackBox, "grpdoompool"), "onUpdate", onDoomChanged);
end

function onDoomChanged()
local nDoom = DB.getChild("TrackBox", "grpdoompool").getValue();
Debug.console("nDoom:", nDoom);

setValue(string.format("%2d", nDoom));
end

</script>

</label>


So to try and clear up: How do I get the value in "grpdoompool" and show it in "gmdoompool"? Any help would be appreciated.

damned
August 31st, 2019, 00:33
Have a look at the Combat Tracker.
It has a GM view and a Client/Player view.
It is the SAME window but one displays more/less than the other.

Moon Wizard
August 31st, 2019, 01:35
Also, all data that is shared between GM and player is stored in the database. Only database nodes which are marked public, or which are owned by the player, will be seen by the player. For example, the combat tracker, party sheet and options are a few examples of database branches that are marked as public, so that data can be accessed on the player side. You'll need to do something like that; so looking at those implementations will be helpful.

Regards,
JPG

Ranzarok
August 31st, 2019, 04:35
Thanks to both of you, I will check out the CT.