PDA

View Full Version : Fields of the Desktop, seen by host and client



Ardem
December 14th, 2013, 10:21
I trying something different, and could use a little help.

I want to add a windows class on the desktop, which sits under desktopclasses.xml. It is a timecounter, for campaign reasons. However it does not create a node.

When opening a window you use the registerStackShortcut that creates the node example.

DesktopManager.registerStackShortcut("button_rmcrandom", "button_rmcrandom_down", "Randoms", "fgrandom", "randomdata");

I created a node using onInit script
timecounter = DB.createNode("timecounter");
and the fields
timecounterday =timecounter.createChild("day","number");
timecounterminute =timecounter.createChild("minute","number");
timecounterhour=timecounter.createChild("hour","number");

My problem is the windowclass does not seem to link with the DB, just wondering can anyone point me in the right direction here. At first I just used code to enter direct into the DB and update the fields, however this does not help me push the information to the players.


This is the windows class.


<windowclass name="timecounter">
<sizelimits>
<minimum width="120" height="75" />
</sizelimits>
<noclose />
<script file="desktop/scripts/timecounter_entry.lua" />
<sheetdata>
<genericcontrol name="base">
<bounds>0,0,150,75</bounds>
<icon>timecounter</icon>
</genericcontrol>
<numberfield name="day">
<bounds>15,15,50,42</bounds>
<font>timecounter</font>
<displaysign />
<readonly />
<right />
</numberfield>
<numberfield name="hour">
<bounds>60,15,50,42</bounds>
<font>timecounter</font>
<readonly />
<right />
</numberfield>
<numberfield name="minute" source="timecounter.minutes">
<bounds>90,15,50,42</bounds>
<font>timecounter</font>
<readonly />
<right />
</numberfield>
<stringcontrol name="label">
<bounds>0,5,150,12</bounds>
<font>timecounterlabel</font>
<static>DAYS PASS SINCE X TIME</static>
<center />
</stringcontrol>
<stringcontrol name="label">
<bounds>97,15,5,42</bounds>
<font>timecounter</font>
<static>:</static>
<center />
</stringcontrol>
<buttoncontrol name="minuteplus">
<bounds>104,50,12,12</bounds>
<state icon="button_plus" />
<script>
function onClickRelease()
window.minutesplus();
end
</script>
</buttoncontrol>
<buttoncontrol name="minuteminus">
<bounds>118,50,12,12</bounds>
<state icon="button_minus" />
<script>
function onClickRelease()
window.minutesminus();
end
</script>
</buttoncontrol>
<buttoncontrol name="hourplus">
<bounds>70,50,12,12</bounds>
<state icon="button_plus" />
<script>
function onClickRelease()
window.hoursplus();
end
</script>
</buttoncontrol>
<buttoncontrol name="hourminus">
<bounds>84,50,12,12</bounds>
<state icon="button_minus" />
<script>
function onClickRelease()
window.hoursminus();
end
</script>
</buttoncontrol>
<buttoncontrol name="dayplus">
<bounds>20,50,12,12</bounds>
<state icon="button_plus" />
<script>
function onClickRelease()
window.daysplus();
end
</script>
</buttoncontrol>
<buttoncontrol name="dayminus">
<bounds>34,50,12,12</bounds>
<state icon="button_minus" />
<script>
function onClickRelease()
window.daysminus();
end
</script>
</buttoncontrol>
</sheetdata>
</windowclass>

Ardem
December 14th, 2013, 11:39
After reading a bit more it might not be possible since it is a panel

This is from the wiki about Panels
"The panel definition creates controls on the desktop. A window instance with the specified window class is created in the panel. The window instance is created without a data source."

Can this be confirmed, if it is possible or not to datasource fields in a panel.

Trenloe
December 14th, 2013, 15:46
At first I just used code to enter direct into the DB and update the fields, however this does not help me push the information to the players.
I have similar functionality for the destiny tokens in the Star Wars: Edge of the Empire ruleset. I use the OOB messaging functionality to push updates to the players from the GM side.

I don't know the answer to your question about panels being created without a datasource or if this means that controls in that panel can't be assigned a datasource.

Remember that if you want players to access a node in the database they must be added as a holder, or (in FG 3.0) register the database node as public so that all players can access the node. I don't know exactly where your issue is, so just thought I'd add this as a reminder and mention the new FG 3.0 public functionality.

Ardem
December 15th, 2013, 00:01
Definitely have them added as a holder with this command oninit. And is working.

User.onLogin = onLogin;

function onLogin(username, activated)
DB.createNode("timecounter").addHolder(username,false);

I done something similar in my Random Extension but never as a panel, just as a standard window launch on button. But I wanted this timeclock not a button launch but already on the desktop.

It is for 3.0, so I better read up on the public functionality, that may help cause even forcing the client to read the DB, onInit does not work,(but does as GM) even if they are a holder.

minute.setValue(DB.getValue("timecounter.minute"));

Pushing details to the Chat window by OOB is an option I guess but I rather want it permanently displayed for them, I probably work it back to a launch button window if I go down that past.I do have it working all GM side at the moment as I pushing it to both a datasource in code and then to the window object, just cannot a) push to code to the client window object, or force a refresh on the client side as there is no linkage to the datasource so the client does not know there has been a change.

Trenloe
December 15th, 2013, 00:35
I'm not sure if you can read the database directly through control in panels - as you mentioned before about maybe not being able to give control in a panel a datasource.

As mentioned above, I used the OOB message functionality - the GM has a function that is tied to the databasenode onUpdate event that gets the update and then sends the data via an OOB message that all of the clients are subscribed to. In CoreRPG 3.0 have a look at the whisper functionality in \scripts\manager_chat.lua. OOBManager.registerOOBMsgHandler(OOB_MSGTYPE_WHISP ER, handleWhisper) registers the OOB registration that is done on the GM side and all clients. Then the GM can call this in processWhisperHelper with Comm.deliverOOBMessage(msgOOB) - with msgOOB containing all of the data needed. This triggers handleWhisper on all clients so you can use something similar for your timercounter.

Have an OOBMessageHandler that runs a function on all FG instances when called. Have the GM side construct the msgOOB object with all of the timercounter details and then deliver to OOB Message to all clients - the handler script will run on each client. In the handler script extract the timercounter details from msgOOB and use the information to populate the controls in the panel.

On the GM side you can write code to populate the DB when the time in the controls is changed. This would trigger the databasenode onUpdate function, which would use the OOB functionality as mentioned above.

It takes a while to get your head around the OOB functionality - it is worth spending the time as it is a powerful and very useful tool in passing data and kicking off scripts on other FG instances.