View Full Version : Easiest Databasenode Storage?
Velocinox
April 23rd, 2010, 22:55
I would like to store a very simple DatabaseNode with the owner's name, a number and a dice type (d6, d8, d10, etc)
Could someone show me the syntax or point me to the code in one of the rulesets?
I've tried NodeManager.createSafeChild(window.getDatabaseNode (), "Name", "Dice");
but all I get is the focused control's scope and this as a child...
<id-00001>
<holder name="Test" owner="true" />
</id-00001>
TIA for any help.
Moon Wizard
April 24th, 2010, 07:39
What context are you making the createChild call from? The result of the createChild call should be the databasenode just created if successful, or return nil if not successful.
Also, I'm not positive, but the type of the node might be case-sensitive, so you should try changing the type value to "dice".
Cheers,
JPG
Velocinox
April 24th, 2010, 22:30
I actually got it to work last night after I posted that but I got into getting the code done and forgot to post...
This is the code I used;
local node = NodeManager.createSafeChild(window.getDatabaseNode (), "cover", "number");
if node then
getDatabaseNode().getParent().getChild("cover").setValue(2);
The context is a menu selection on the number of attacks control on the weaponlist window on the charsheet_combat.xml page. (D20_JPG) and storing the attack type value the player chose in the database and then picking it back up in the chat_chat.xml where it makes the adjustments to the attack roll and hit location roll
What I am doing is making an extension that will allow hit location and D20_modern attack types (burst, autofire, double tap, etc.) to be selected before the attack is rolled and it will mark off the ammo automatically apply any inherent penalty to the attack type, and roll an appropriate hit location check.
I had the hit location in place (d20 for full body hit locations) and not use cover penalties but if the hit location came up with an body part behind cover it hit the cover instead and worked from there (cover's DR, hit points, does it pass through, etc.)
However after getting that done I decided I wanted to give the players a choice of no 'to-hit' penalty for a full body hit location and just take their chances on hitting the cover (like I descibed above) OR they could aim for a part of the body and take a penalty to hit but a smaller hit location roll that only includes the exposed parts of the target's body. That required that I let the player select that before the attack and roll a smaller hit location chart than the full d20 (e. g., shooting at a 1/2 cover target that is splint vertically as if half behind the corner of a building would require a to-hit penalty the same as 1/2 cover AND limit the hit location roll to 1d10, the half of the body exposed)
Ok, getting off topic, let me know if you see anything wrong with the code. It works but may not be entirely the best way to do it.
Thanks for the reply.
Velocinox
April 25th, 2010, 09:16
Oh, I don't believe this...
I did all that work and realized I could do everything much easier and without modifying the charsheet element just by using the DB package.
Oh well, hard learned lessons are the last forgotten.
Powered by vBulletin® Version 4.2.1 Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.