DICE PACKS BUNDLE
  1. #1

    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

  2. #2
    Zeus's Avatar
    Join Date
    Mar 2009
    Location
    Olympus
    Posts
    2,658
    Blog Entries
    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
    Now, add the following function to the same script block.

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

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

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

  5. #5
    I found a way.

    y.link.getTargetDatabaseNode() works.

    Fenloh

  6. #6
    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
    Last edited by Fenloh; August 21st, 2011 at 18:01.

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Starfinder Playlist

Log in

Log in