-
November 26th, 2023, 13:02 #1
DB personalized node - GM/player differences
I would like to create a section of the DB in which we can save some specific information related to the game system that my friends and I are creating.
The structure should be this:Code:<test> <playername1> data </playername1> <playername2> ... </playername2> ... </test>
Code:Interface.openWindow("testrecord", "test." .. User.getUsername() );
Code:<test> <GM> data </GM> </test>
What am I doing wrong? Because I'm definitely doing something wrong.
-
November 26th, 2023, 13:31 #2
I would imagine that if you look in the console.log file there will be a message/warning indicating that the player instance doesn't own the <test> node in the database. A player instance can only modifiy database nodes if they are a holder of that node.
I don't know if there's a better way to do this, but my recommendation would be code the creation of the base node that the windowclass "testrecord" in the GM instance when a player logs in to the campaign - you can use the User.onLogin hanlder: https://fantasygroundsunity.atlassia...3/User#onLogin
The GM instance should also make the player the "holder" of the new node - allowing that one user to change data under the node. You can see this in the db.xml for a campaign - have a look in the charsheet node - any PCs that are owned will have entry like this: <holder name="Trenloe" owner="true" />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!
-
November 26th, 2023, 14:49 #3
Ty @Trenloe, thanks to your suggestions I solved adding this code to my ruleset manager:
Code:function onTabletopInit() User.addEventHandler("onLogin", MyRuleset.onClientLogin); end function onClientLogin(sUser, bActivated) if bActivated then local oUserNode = DB.createNode("test." .. sUser); DB.setOwner(oUserNode, sUser); end end
-
November 26th, 2023, 17:02 #4Private 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!
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks