Thread: CT Holder, Owner
-
August 20th, 2011, 11:54 #1
Grand Templar
- Join Date
- Sep 2008
- Posts
- 274
CT Holder, Owner
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
-
August 20th, 2011, 14:33 #2
Maybe something like this.
in the onInit() function of the CT window, add the following code:
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
Code: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
FG Project Development
Next Project(s)*: Starfinder v1.2 Starship Combat
Current Project: Starfinder v1.1 - Character Starships
Completed Projects: Starfinder Ruleset v1.0, Starfinder Core Rulebook, Alien Archive, Paizo Pathfinder Official Theme, D&D 5E data updates
* All fluid by nature and therefore subject to change.
-
August 21st, 2011, 14:08 #3
Grand Templar
- Join Date
- Sep 2008
- Posts
- 274
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.
-
August 21st, 2011, 14:20 #4
Grand Templar
- Join Date
- Sep 2008
- Posts
- 274
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
-
August 21st, 2011, 16:16 #5
Grand Templar
- Join Date
- Sep 2008
- Posts
- 274
I found a way.
y.link.getTargetDatabaseNode() works.
Fenloh
-
August 21st, 2011, 17:54 #6
Grand Templar
- Join Date
- Sep 2008
- Posts
- 274
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
function addWatcher (sNode, sUser, bOwner)
if not bOwner then
bOwner = false
end
DB.addHolder(sNode, sUser, bOwner);
endLast edited by Fenloh; August 21st, 2011 at 18:01.
-
August 21st, 2011, 18:06 #7
Grand Templar
- Join Date
- Sep 2008
- Posts
- 274
Sorry, it is my fault... i am setting the combattracker holder, not that of the id... sigh
fenloh
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks