PDA

View Full Version : giving players access to npcs, items, etc.



KyleC
June 25th, 2007, 17:15
Is there a way to give players access to data other than just the charsheet node? For example, I'd like to be able to link npcs and items to a character sheet, allowing the player to view and modify the linked objects. As it stands now, the player can click the link and open the appropriate window but he does not have access to the underlying data.

joshuha
June 25th, 2007, 17:34
Yep each windowclass can have a <sharable> tag that makes it sharable. I would suggest adding the viewerlist control to anything you make sharable so you can see who is looking at it.

Also, as noted in the other thread, be wary of any custom controls added at runtime though because it does rebuild the windowclass and then relink to the DB nodes. For things like items and NPCs this should work ok.

Although with anything in a module you would need to make sure they had the module open whe you shared it otherwise they will probably get an error.

KyleC
June 25th, 2007, 18:22
A few issues:

1) Does the <shareable> tag cause the windowclass to work like a map window, wherein the host manually shares it with the players? If so, that isn't the functionality I'm going for. I'd like for a player to simply click on a link on their character sheet to pull up the npc window, without intervention from the host.

2) Assuming (1) is correct, I'm having trouble getting the tag to work properly in the first place. I've placed <shareable /> in every windowclass in adventure_npcs.xml, but I do not get the option to share the window during runtime.

3) I also added <playercontrol /> just to see what happened. Nothing did, as far as I could tell.

4) The goofy part: As the host, I create an npc, and drop its link on the character sheet. When clicking the link, everything works fine: the window pops up and the data is visible. Then as the player, when I click the link, the npc window comes up but none of the data is there. At this point, the npc's <name> field within db.xml is deleted, so that the host no longer sees the npc by its original name, but as << New Personality >> instead.

Any thoughts on what I'm doing wrong?

joshuha
June 25th, 2007, 18:40
A few issues:

1) Does the <shareable> tag cause the windowclass to work like a map window, wherein the host manually shares it with the players? If so, that isn't the functionality I'm going for. I'd like for a player to simply click on a link on their character sheet to pull up the npc window, without intervention from the host.


No, its only initiates it from the host side. However, all windowinstances have a Share() function that you could cause your link to spawn.



2) Assuming (1) is correct, I'm having trouble getting the tag to work properly in the first place. I've placed <shareable /> in every windowclass in adventure_npcs.xml, but I do not get the option to share the window during runtime.


Its <sharable />. You have an extra 'e' i there.



3) I also added <playercontrol /> just to see what happened. Nothing did, as far as I could tell.


Playercontrol gives them full options once the window is shared to them. This means they can close for all, close it, or even deleted the DB.node that window is tied to (if you turn this on I suggest using <nodelete /> to remove that option).




4) The goofy part: As the host, I create an npc, and drop its link on the character sheet. When clicking the link, everything works fine: the window pops up and the data is visible. Then as the player, when I click the link, the npc window comes up but none of the data is there. At this point, the npc's <name> field within db.xml is deleted, so that the host no longer sees the npc by its original name, but as << New Personality >> instead.

Any thoughts on what I'm doing wrong?

Not sure if this is related to the above. One the sharable is in there properly (or you call the windowinstance Share) this should behave properly as long as its linked to the db.xml correctly as far as the datanode is concerned.

KyleC
June 25th, 2007, 20:01
Its <sharable />. You have an extra 'e' i there.

Yeah, but it's a silent e. I didn't think it'd cause any trouble. :)

I'm getting closer. The player can now see the data after the host shares it, but he cannot edit any of the data (except, interestingly enough, my custom controls).

If the player clicks the link on his character sheet before the host shares it, I get the same problem listed in my previous post. However, after sharing the window, even if the host subsequently closes it, clicking the link works just fine.

Sounds like I need to create a custom control that simulates a link but in actuality sends the host a message to share a particular resource. Assuming, of course, that data modification is even possible for the player in the first place.


Playercontrol gives them full options once the window is shared to them. This means they can close for all, close it, or even deleted the DB.node that window is tied to (if you turn this on I suggest using <nodelete /> to remove that option).

The only additional capability <playercontrol /> has provided in my ruleset is the ability to close the window when it is shared. Ordinarily the player cannot do so unless the host closes it for everyone.

You've been extremely helpful with your advice. If I ever get this ruleset up and running, I'll name the first villain after you. :)

The High Druid
June 28th, 2007, 15:43
Hmmm. Could you not create a player-usable module to achieve this? You could put the NPC and Item data into modules for players to view. Hmmm, but I guess it doesn't allow the editing you're after.

KyleC
June 28th, 2007, 18:27
From my testing, I've finally realized that a client cannot edit data unless it is both the holder and owner, via the following tag in the db.xml:

<holder name="JohnDoe" owner="true" />

When a player selects a character, it appears that this tag is automatically added to all the appropriate spots in <charsheet>. Is this hardcoded in the application to do this? Is there a way to add this tag to other sections of the db (without having to traverse the xml tree and manually adding the tags myself)? Alternatively, is there a setting which would allow the dbto not require the tag in order to be modified?

EDIT: Interestingly, a custom control which adds data to the database programmatically does not have this restriction. It seems to be something hardcoded to the base controls themselves.

joshuha
June 28th, 2007, 18:57
https://www.fantasygrounds.com/refdoc/databasenode.xcp

Look at the addholder() function, you can past a true on the second parameter to make them the owner to with full edit rights.

KyleC
June 28th, 2007, 20:16
https://www.fantasygrounds.com/refdoc/databasenode.xcp

Look at the addholder() function, you can past a true on the second parameter to make them the owner to with full edit rights.

I had just logged in to say that I found the addHolder() function, but you beat me to it. I'll play around with this later when I get the chance.