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