STAR TREK 2d20
  1. #1

    New question of the day: how to use setHolder

    OK. My extension now is able to create, retrieve, update and delete data from the DB when run on the host. In addition, I figured out that if I go into the db.xml and add a "holder" tag to one of the entries, then a player can modify or delete that entry. A player still cannot add a new entry.

    It has something to do with the way I'm creating a new node. I'm using something like:
    Code:
    local node = window.getDatabaseNode().createChild();
    which works fine for the host, but node is set to 'nil' for the player.

    I know once I have a node created, I can use addHolder to associate it with the player, but how do I do that when the node is nil?

    Obviously, I'm missing something. Who would like to be my helpful educator today?

    BTW: I was wrong about being able to use addHolder. Only the GM can do that. I found out by actually trying it. So much for what "I know"...
    Last edited by jreddin1; June 29th, 2015 at 20:52.

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,362
    Set the holder on the base (parent) node before you create the child.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  3. #3
    Hmm. Interesting idea, but doesn't work. A player can't add a holder to a node -- only the GM can. I can't add a holder for every player that joins, either, because then they would all see each others entries. Not something I want.

    As far as I can tell, the only way to do this is to use:
    Code:
    Interface.requestNewClientWindow("some_window", window.getDatabaseNode().getNodeName());
    That's basically how Notes works. It also adds the node with the "holder" tag in place and ready for the player to use. The only thing is, it forces you to open a new window, while adding a DB node. It works, but it's not what I really want.

    The way I want it to work, is how it already works on the GM screen: You hit the add button, a new entry appears on the windowlist, and you can edit the entry in place. Nice and clean, easy and obvious. That's what I want the Player to be able to do.

    Instead, on the player side, I have to rig it so that when you click 'add', a new window gets created with the new node (which also shows up on the windowlist), that the player can enter data on and close. The entry gets added to the windowlist (although, I haven't figured out how to automatically propagate the change in the window to the entry in the list).

    I'm looking at windowlist.createWindow and windowlist.createWindowWithClass, but I'm not hopeful.

  4. #4
    windowlist.createWindowWithClass() doesn't work either. It works great at adding an entry to the list. It just can't create a DB node for it. So far, the only way I've found for a player to create a new node is using Interface.requestNewClientWindow().

    That sucks. Hopefully, someone knows a different way to go.

  5. #5
    Yes, all requests for a player to create a new child node under a parent node they don't own must go through the GM machine. The requestNewClientWindow is one way to do that, and the other way I've seen is to send a special OOB message to the host and take an action based on that message (i.e. create DB entry, add holder, open window, share to player).

    Regards,
    JPG

  6. #6
    I saw the OOB message, but hadn't really looked into it. That sounds like it might be what I need. I'm going to play with it, and let you know.

    Thanks!

  7. #7
    OOBMessage works great! It let's me do EXACTLY what I was looking for! Thank you very much! I will be using that a lot more, I think.

    Now if I can just get the button cycler to work correctly... I'm so close to having this extension done I can taste it! (And then I'll be writing part 2 of my too long tutorial!)

  8. #8
    jreddin1, do you mind sharing what you're working on?
    +2 License of Ultimate Hosting
    Current Projects: Murder in Baldur's Gate Module
    Completed Projects: Curse of Strahd module, Sword Coast Adventurer's Guide Module, Out of the Abyss Module, Legacy of the Crystal Shard Module, Scourge of the Sword Coast Module, Effect Targeting Extension (5e), Unearthed Arcana: Vitality Extension

  9. #9
    I did a tutorial on creating a window as Part I of a series I'm planning on doing. As part two, I'm adding content to that window that allows the players to enter different types of messages that they use frequently, and then be able to send those with a single button click. I've attached a picture of what it looks like.

    Attachment 10387

  10. #10
    Fixed the button cycler problem. It was a race condition. When the host received the OOB message and creates the node, the player received the node update before the host could set the holder tag. The trick was just to find the right place to check the button against the node and reset as needed. Actually, final code fix was basically:

    Code:
    btn.setReadOnly(srcnode.isReadOnly());

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
  •  
5E Character Create Playlist

Log in

Log in