PDA

View Full Version : CT Holder, Owner



Fenloh
August 20th, 2011, 11:54
Hi,

i am having a bit of a problem. I add a player to the CT then all the necessary Nodes are being created, but with no Holder/owner.

If a player logs in and opens the CT a holder Tag for all nodes that the client is allowed to see is added to the nodes.

I do have the problem, that the playerchar itself is not added with the owner tag to the holder. If the player now tries to roll initiative a warning is issued, that he is not the owner of that specific node.

I want to make the correct player the holder and owner of that specific node, once it is entered in the database.

Any suggestions?

Fenloh

Zeus
August 20th, 2011, 14:33
Maybe something like this.

in the onInit() function of the CT window, add the following code:



for k,v in ipairs(User.getAllActiveIdentities()) do
local username = User.getIdentityOwner(v);
if username then
for x,y in ipairs(list.getWindows()) do -- check the name of the windowlist in the CT for your ruleset.
if y.name == v then
addWatcher("combattracker", username, true); -- check the name of the CT window for your ruleset.
else
addWatcher("combattracker", username, false); -- check the name of the CT Window for your ruleset.
end
end
end
end

Now, add the following function to the same script block.


function addWatcher (sNode, sUser, bOwner)
local node = DB.findNode(sNode);
if not node then
node = DB.createNode(sNode);
end

if node then
if bOwner then
node.addHolder(sUser, true);
else
node.addHolder(sUser, false);
end
end

That should add holder tags to the ctwindow database nodes for all connected users, therefore adding read ability to the nodes. It also loops through the CT window entries matching name of character to Identities from GetActiveIdentities and will add ownership rights to the correct entry.

Fenloh
August 21st, 2011, 14:08
Nope, i dont get it.

first you get all active Identites. which means all active Chars, no matter who the User ist. v is returned r.g as id-0001
For each active Identity you get the Username (e.g. User1), just to see if it is available. (I am not sure if it is even possible to haven an active Identity without a user)

then you get, for each window in the windowlist Combattracker, a windowinstance (y) with y.name you return the stringcontrol (with name and x,y axe and width and height)

then you compare y.name with the v, the id number.

I dont see how that fits, or am i getting it wrong?

The addWatcher is also already in the Nodemanager in the new Ruleset. I can easily adapt it if i add a third variable (ownership). since i set it to "false" if it is not defined it does not change the use of the addWatcher function.

Fenloh
August 21st, 2011, 14:20
in the combattracker there is a DB node recordname, but it seems that i cannot get to it.

y.link is "WINDOWCONTROL = { nil }
y.link.recordname is nil
y.recordname is nil

how do i get the recordname, which is the charcheet node? from there i can get the owner and if owner and user are the same then i can set the watcher as holder with the ownerflag.

Fenloh

Fenloh
August 21st, 2011, 16:16
I found a way.

y.link.getTargetDatabaseNode() works.

Fenloh

Fenloh
August 21st, 2011, 17:54
Strangely there is now another Problem that i am not able to solve.

As you can see below the combattracker node has also a holder, who is the owner. The problem now is, that he is the only owner to the whole tree. I am not sure why the holder is set to Owner....


<combattracker>
<holder name="player" owner="true" />
<id-00002>
<holder name="player" owner="true" />



this is the function i use;


function addOwnerShip()
for k,v in ipairs(User.getActiveUsers()) do
for x,y in ipairs (getWindows()) do
if y.type.getValue() == "pc" then
local nodeOwner = y.link.getTargetDatabaseNode();
local sOwner = nodeOwner.getOwner();
if sOwner == v then
NodeManager.addWatcher("combattracker", v, true);
else
NodeManager.addWatcher("combattracker", v, false);
end
end
end
NodeManager.addWatcher("combattracker_props", v);
end

end


combined with the nodemanager Function


function addWatcher (sNode, sUser, bOwner)
if not bOwner then
bOwner = false
end
DB.addHolder(sNode, sUser, bOwner);
end

Fenloh

Fenloh
August 21st, 2011, 18:06
Sorry, it is my fault... i am setting the combattracker holder, not that of the id... sigh

fenloh