DICE PACKS BUNDLE
  1. #1
    Xarxus's Avatar
    Join Date
    Mar 2019
    Location
    Rome (Italy)
    Posts
    262

    User.requestIdentity - invoke host function

    If I understand correctly how User.requestIdentity works, it is used when it is necessary to generate a record. From what I've seen, the idea behind its use is that the creation is always done by the host, I imagine to avoid the generation of duplicate IDs.

    The behavior should be this:

    Event
    --> if Host --> record generation
    --> if client --> generation request to the host with indication of the host function that must perform the activity. The host function receives two parameters indicating whether it succeeded in creating a new ID and the ID to use.

    Did I get it right?

    Assuming that I have understood correctly how the code should be organized if instead of creating a single record, the request must perform the creation of n records (perhaps with a loop)?
    I imagine if the event occurs on the host there would be no problem, but what about the client? Should the client make the request to generate inside a loop? And what happens if for each record generated, other subrecords must be generated (a nested list)?

    What I need to generate I have a structure like this:

    Code:
    <mylist1>
    	<id-00001>
    		... fields
    		<mylist2>
    			<id-00001>
    				... other fields
    			</id-00001>
    			<id-00002>
    				... other fields
    			</id-00002>
    		</mylist2>
    	</id-00001>
    	<id-00002>
    		... fields
    		<mylist2>
    			<id-00001>
    				... other fields
    			</id-00001>
    		</mylist2>
    	</id-00002>
    	<id-00003>
    		... fields
    		<mylist2>
    			<id-00001>
    				... other fields
    			</id-00001>
    			<id-00002>
    				... other fields
    			</id-00002>
    			<id-00003>
    				... other fields
    			</id-00003>
    		</mylist2>
    	</id-00003>
    	...
    </mylist1>
    I think it's simple to add an element to mylist2 using User.requestIdentity, just pass it the correct node (e.g.: node -_> mylist1.id00002.mylist2), but what if I wanted to add an element to mylist1 and inside it n elements to mylist2?

    And what if I have to generate the entire mylist1 structure with all elements (id0001, id0002, etc.)?

    Is there a way to invoke a function on the host, regardless of generating an ID? If that were the case, the host function would do the generation, so I wouldn't have to worry about duplicate IDs.
    FGU ULTIMATE License
    Click here for RPG Music or here for Dwarves songs on Spotify

  2. #2
    You should not use the User.requestIdentity for anything. It is purely a simple API to generate new character sheets, based on a few other settings.

    If you want a Player client to send a request to the Host client to generate a record on a record not owned by the player, you should use a OOB message to send a request to the host, which the host can then use to add a new sub-record using the information in the OOB message. (For consistency, you can send the message on both Host and Player instances with a target of Host only; and the Host will handle either source.) There are many examples of that in the existing rulesets (in CoreRPG, it's used in DiceTowerManager, EffectManager, ItemManager, LanguageManager, and more.)

    Regards,
    JPG

  3. #3
    Xarxus's Avatar
    Join Date
    Mar 2019
    Location
    Rome (Italy)
    Posts
    262
    So, if the record is owned by the client, it can be generated directly?
    Is there a function to get a new ID?
    FGU ULTIMATE License
    Click here for RPG Music or here for Dwarves songs on Spotify

  4. #4
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,470
    Quote Originally Posted by Xarxus View Post
    Is there a function to get a new ID?
    Are you referring to the database id-XXXXX intermediate node name? If so, use DB.createChild without a "type": https://fantasygroundsunity.atlassia...DB#createChild
    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!

  5. #5
    Xarxus's Avatar
    Join Date
    Mar 2019
    Location
    Rome (Italy)
    Posts
    262
    Yes, I am referring to id-xxxxx. If I don't specify the name, does createChild increase the id by itself?
    FGU ULTIMATE License
    Click here for RPG Music or here for Dwarves songs on Spotify

  6. #6
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,470
    Quote Originally Posted by Xarxus View Post
    If I don't specify the name, does createChild increase the id by itself?
    Yes (kinda): "If this parameter is omitted, a new unique node name will be generated." Usually it will increase the ID number, but if there is an earlier "space" then that may be used instead.
    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!

  7. #7
    Xarxus's Avatar
    Join Date
    Mar 2019
    Location
    Rome (Italy)
    Posts
    262
    That's good!

    Ty
    FGU ULTIMATE License
    Click here for RPG Music or here for Dwarves songs on Spotify

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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 Product Walkthrough Playlist

Log in

Log in