Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

TAS: Supposed to be easy...it's not. Or am I missing something.

1549297524

Edited 1549298556
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
This is supposed to be easy. I want to have the esl "Effective Skill Level" be the sum of "ad_bonus", "lvl", & " total_ad_mod ". What am I missing? on('sheet:opened change:repeating_defense change:total_ad_mod', function () { TAS.repeating('defense') .attrs('total_ad_mod') .fields('esl', 'ad_bonus', 'lvl') .each(function(r){ r.esl = r.ad_bonus + r.lvl + total_ad_mod; }) .execute(); }); Updated and still not quite there.
1549301365
Finderski
Pro
Sheet Author
Compendium Curator
I believe you're calling the wrong portion...here's a call I use on the Savage Worlds Tabbed sheet: on('change:repeating_augmentation remove:repeating_augmentation',function(){ TAS.repeatingSimpleSum('augmentation','augStrain','totalStrain'); }); Does that help?
1549302149
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
Not trying to do a simple sum On the same row: esl = total_ad_mod + ad_bonus + lvl. total_ad_mod is an attr. I need to add it in to the calculations // Update Lines on Defense on('change:repeating_defense change:total_ad_mod', function () { TAS.repeating('defense') .attrs('total_ad_mod') .fields('esl', 'ad_bonus', 'lvl'') .each(function (r) { r.D[0].esl = r.F.ad_bonus + r.F.lvl + r.F.total_ad_mod; }) .execute(); });
1549302399
The Aaron
Roll20 Production Team
API Scripter
Need to add a second argument to the each for attributes and reference attributes on it: .each(function(r,a){ r.esl = r.ad_bonus + r.lvl + a.total_ad_mod; })
1549302666

Edited 1549302790
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
Like this? // Update Lines on Defense on('change:repeating_defense remove:repeating_defense change:total_ad_mod', function () { TAS.repeating('defense') .attrs('total_ad_mod') .fields('esl', 'ad_bonus', 'lvl') .each(function(r,a){ r.esl = r.ad_bonus + r.lvl + a.total_ad_mod; }) .execute(); });
1549303012
The Aaron
Roll20 Production Team
API Scripter
Yeah. The first parameter will be all the fields in the correct row. The second will be all the attributes specified to attrs(). 
1549304508
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
So this sheet worker sets the total_ad_mod // Update Active Defense Modifier // Ref. B374 on("sheet:opened change:dodge change:current_dodge change:combat_reflexes change:trained_by_master change:weapon_master change:ambidextrouse change:manuever change:posture change:fencing change:parryweapon change:unarmed_parry change:mpp change:def_above_atkr change:condition_ad_penalty change:ad_bad-foot change:ad_cant-see-attacker change:ad_mounted change:shieldDB change:acro_dodge change:ad_dodgeanddrop change:ad_feverish_defense change:opp change:ad_retreat", function (e) { console.log('****** Update Active Defense Bonus ******'); getAttrs(["parryweapon", "unarmed_parry", "mpp", "def_above_atkr", "condition_ad_penalty", "ad_bad-foot", "ad_cant-see-attacker", "ad_mounted", "shieldDB", "acro_dodge", "ad_dodgeanddrop", "ad_feverish_defense", "opp", "ad_retreat", "combat_reflexes", "man_def_mod", "posture_defend"], function(v) { var vals = Object.values(v); vals.push(0); setAttrs({ total_ad_mod: vals.reduce(getSum) }); }); });
1549304570
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
And this one is getting an error when it calls the total_ad_mod // Update Lines on Defense on('change:repeating_defense remove:repeating_defense change:total_ad_mod', function () { TAS.repeating('defense') .attrs('total_ad_mod') .fields('esl', 'ad_bonus', 'lvl') .each(function(r,a){ r.esl = r.ad_bonus + r.lvl + a.total_ad_mod; }) .execute(); });
1549304660

Edited 1549304839
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
The resulting esl will usually be positive but can be negative to indicate no defense possible. what I am getting is "0140" What it seems to be doing is concating the numbers.
1549305042
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
I have the solution! // Update Lines on Defense on('change:repeating_defense remove:repeating_defense change:total_ad_mod', function () { TAS.repeating('defense') .attrs('total_ad_mod') .fields('esl', 'ad_bonus', 'lvl') .each(function(r,a){ r.D[0].esl = r.I.ad_bonus + r.I.lvl + a.I.total_ad_mod; }) .execute(); });
1549306305
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
Thanks Aaron for the quick clarification!!
1549308245
The Aaron
Roll20 Production Team
API Scripter
Great!  Yeah, sorry, I should have mentioned that earlier. You can use .F if you need decimal places. 
1549308371
The Aaron
Roll20 Production Team
API Scripter
You can use r.I instead of r.D[0]. Shouldn’t make any real difference, just means it converts to a string earlier in the process, possibly twice. Super minor inefficiency. 
1549308529
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
Actually, I will be implementing that in another part of my sheet. I still have to implement this in melee and ranged repeating sections. Again thanks for your amazing help.