PDA

View Full Version : Need some Script Help



Samarex
March 21st, 2017, 04:03
I have a setup on a 3.5E ruleset Charactersheet and I am trying to automate it but not sure how to make the script to do it.

Setup is

String, number-field A, Number-field b, number-field c, number-field d
Alignment Law Chaos Good Evil


First thing is
I need Set 1 (A and B) tied together in the manner if A increases by 1 then B decreases by 1 or if A decreases 1 then B increases 1, with scores of 0-21 (Combine Score MUST be 21) Same with Set 2 (C and D)
Second
I would like the String to auto update depending on the following rules
Set 1
If Scores are all between 8-13 then String is Neutral
If either A or B is 14 or greater then that Field is used (Example A-14,B-8 would give a Law Alignment, A-8,B14 a Chaos)

Set 2
If Scores are all between 8-13 then String is Neutral
If either C or D is 14 or greater then that Field is used (Example C-14,D-8 would give a Good Alignment, C-8,D14 a Evil)

Combine Set 1 and Set 2 and generate String field
Example 11,11,11,11 would be Neutral
14,8,11,11 -Lawful Neutral
11,11,14,18 -Neutral Good
14,8,14,8 Would Be Lawful-Good

Character Sheet Code


<frame_char name="alignmentframe">
<bounds>15,45,480,45</bounds>
</frame_char>
<string_labeled name="alignmentlabel">
<anchored to="alignmentframe" position="insidetopleft" offset="15,10" width="115" height="20" />
<labelres>char_label_alignment</labelres>
</string_labeled>
<number_strscoreadj name="alignmentlaw" source="abilities.alignment.scorelaw">
<anchored to="alignmentframe" position="insidetopleft" offset="195,13" />
<default>11</default>
</number_strscoreadj>
<string_charalignmentlabel>
<anchored to="alignmentlaw" />
<static textres="char_label_alignlaw" />
</string_charalignmentlabel>
<number_strscoreadj name="alignmentchaos" source="abilities.alignment.scorechaos">
<anchored to="alignmentlaw" position="right" offset="55,0" />
<default>10</default>
</number_strscoreadj>
<string_charalignmentlabel>
<anchored to="alignmentchaos" />
<static textres="char_label_alignchaos" />
</string_charalignmentlabel>
<number_strscoreadj name="alignmentgood" source="abilities.alignment.scoregood">
<anchored to="alignmentchaos" position="right" offset="55,0" />
<default>11</default>
</number_strscoreadj>
<string_charalignmentlabel>
<anchored to="alignmentgood" />
<static textres="char_label_aligngood" />
</string_charalignmentlabel>
<number_strscoreadj name="alignmentevil" source="abilities.alignment.scoreevil">
<anchored to="alignmentgood" position="right" offset="55,0" />
<default>10</default>
</number_strscoreadj>
<string_charalignmentlabel>
<anchored to="alignmentevil" />
<static textres="char_label_alignevil" />
</string_charalignmentlabel>

Thanks for any help
Samarex

Moon Wizard
March 21st, 2017, 04:46
You would need to link everything together so that editing one field affects the other one. However, this can get complex, because FG only lets you know when a value has changed, not what it was previously.

So, you'll either need to store the current value in the Lua script for the control and use the difference to adjust the other field. Of course, this will mean that the fields will be constantly changing while people type numbers.

Or, I might suggest that you use buttons for up/down and make the fields read only. In that way, the scripting is a little easier, since you can just adjust incrementally, without having to worry about previous values and random number entry.

Regards,
JPG

Samarex
March 24th, 2017, 07:18
Ok @Moon. We have are Ability Score (Str) with Bonus and Damage Blocks. When we put a number in the Damage Block our Str is automatically adjusted on rolls. Where is this adjusted number stored. Whats it called. In my Character sheet Im trying to design for or group I want to display that number on the Character Sheet

Moon Wizard
March 25th, 2017, 18:44
Using strength as an example, the data is stored as:
abilities.strength.score
abilities.strength.damage
abilities.strength.bonus
abilities.strength.bonusmodifier

All of the calculations for rolls are done completely separately as part of the rolling code. See ActionAbility script.

The only calculation done during live play are to the bonus field when the score changes. You'd have to look at the "number_charabilityscore" and "number_charabilitybonus" templates to see how that works.

Regards,
JPG