Thread: getValue() from DB?
-
August 30th, 2019, 23:01 #1
- Join Date
- Jun 2019
- Posts
- 71
getValue() from DB?
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.
Host side window(the value I want to retrieve):
windowclass = trackerwindow
databasenode = TrackBox
Code:<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>
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.
Code:<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>
-
August 31st, 2019, 00:33 #2
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.
-
August 31st, 2019, 01:35 #3
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,557
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
-
August 31st, 2019, 04:35 #4
- Join Date
- Jun 2019
- Posts
- 71
Thanks to both of you, I will check out the CT.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks