Starfinder Playlist
  1. #1

    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>
    Client side window (where I want to display the above value):

    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>
    So to try and clear up: How do I get the value in "grpdoompool" and show it in "gmdoompool"? Any help would be appreciated.

  2. #2
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,678
    Blog Entries
    1
    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.

  3. #3
    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

  4. #4
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Product Walkthrough Playlist

Log in

Log in