PDA

View Full Version : Timing issues



Hamish
February 25th, 2011, 21:20
I'm tinkering with the characterlist, and I think I'm running into some timing issues. I am trying to display each character's initiative in a text widget. To do this I'm creating a database node "init" for each character that is the source of this widget's value. My problem is as follows:
When a new character logs on, the host creates the "init" node for this new character (as part of onIdentityActivated) in the database and adds the players of all existing characters as holders on this node, so they have the permission to read it's value. Then it goes on with the normal stuff of adding an entry to the characterlist and adding the widgets.
In the meantime, all players that are already connected don't have to go through the database modification steps, and try to add an onUpdate handler to the "init" node of the new character. This fails, and I think it's because because the host hasn't finished creating the node and updating permissions yet.

The root cause I think is that there is no other character-specific event than onIdentityActivated, so I am forced to use that for both the database update for the host and portrait creation for the players.

Hope that makes sense to anyone.....

Moon Wizard
February 26th, 2011, 01:56
There is an onLogin event. I use this in the 4E ruleset to share the database nodes for the combat tracker, options, modifiers and effects.

Here's my suggestion:
* Store the initiative in the combat tracker
* Share the combat tracker with each user who logs in
* When charlist entry created, look at the CT to see if you can find a CT entry whose link matches.
* When a new CT entry is created, look at the charlist to see if you can find a charlist entry whose link matches.
* Add an initiative widget when you find a matching link.
* Assign onDelete and onUpdate handlers to the CT init node.
* Update the widget when onUpdate handler is called.
* Remove the widget when onDelete handler is called.

Cheers,
JPG

Hamish
February 26th, 2011, 08:56
Thanks for the reply JPG.

The onLogin event will not work in this case, since it only involves the player and not the character.

There are a few reasons I want to store the initiative value in the charactersheet node:
I'd like the extension to involve as little files as possible, so it's less likely to be impacted by ruleset updates. Although it seems likely that I'll be involving the combat tracker for some other things I want to do with it.
I also want to sort the characterlist portraits by initiative, which I think is a lot harder if it's not stored on the charactersheet.


It's a 3.5E extension by the way....

Moon Wizard
February 26th, 2011, 10:13
You'll have to change the combat tracker anyway, since the initiative is stored there. Even if you add an initiative field to the character sheet, you'll have to create a link to the character sheet field in the combat tracker. (just like the hit point, name, AC, and other fields)

Either way, you're going to have to store a node name and set up onUpdate/onDelete handlers for the node, whether it is in the CT or the charsheet.

Once you have the initiative information stored in the characterlist entry, you can just use the onSortCompare and applySort functions to swap the characters. If you go with the CT node link, you can sort characters without a CT node link to the end of the list.

One benefit of linking to the combat tracker, is that you could also enhance the extension to monitor wounds and effects, and show the additional information on the character list entry. Or you could link to both, and pull information from both. (though I can't think of any information not in the CT I would want to track off the top of my head.)

Cheers,
JPG

Hamish
February 26th, 2011, 19:10
OK, I found another reason I want to keep the init node in the character sheet:
The combat tracker is just way out of my league.... I have no idea how it works. :mad: Sooo many files involved.

Hamish
March 4th, 2011, 15:16
Managed to find a solution keeping the init node in the character sheet. :)
Now onto displaying a flag on the characterlist portrait for the active player in the combat tracker.

Moon Wizard
March 4th, 2011, 20:27
That will be cool. I'd love to see what you have when you're finished.

JPG

Hamish
March 5th, 2011, 10:02
Wow... combat tracker certainly is a lot more complicated than the last time I made this modification.