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

Sheet Script help

So, I'm using The Aaron's Simple Sum script. It does what I need it to do, but I've hit a bit of a hiccup. I have attr_ that-are-hyphenated and I can not for the life of me figure out how to set it up to ignore those and not use them as minus signs. This is the bit I'm trying to get working. on('change:repeating_spells', function(){          TAS.repeating('spells')         .attrs('spell-level1-remaining','spell-level1-total')         .fields('cast-value')         .reduce(function(m,r){             m['cast-value'] = (r.F['spell-level1-total'] - r.I['cast-value']);             r['spell-level1-integer'] = (r.F['spell-level1-total'] - r.I['cast-value']);             return m;                      },{'cast-value': 0, desc []},function(m,r,a){             a.S['spell-level1-remaining'] = m['cast-value'];         })         .execute(); }); I looked through the pathfinder-neceros to get the [''] idea, but it's still not working. Any ideas?
1491082613
Lithl
Pro
Sheet Author
API Scripter
Your syntax appears correct. What are some values of the attributes involved, and what's the result of the script?
cast value is set to 3, spell-level1-remaining is set to 0 and spell-level1-total, I've discovered I cannot use, as it is an autocalc field and only the formula is returned. I fixed it to include the correct attributes, but still nothing. on('change:repeating_spells', function(){          TAS.repeating('spells')         .attrs('spell-level1-remaining','spell-level1-castable','spell-level1-misc','spell-level1-specialist')         .fields('cast-value','spell-level1-integer')         .reduce(function(m,r){             m['cast\-value'] += r.F['spell\-level1\-castable'] + r.F['spell\-level1\-misc'] + r.F['spell\-level1\-specialist'] - r.I['cast\-value'];             r['spell\-level1\-integer'] = r.F['spell\-level1\-castable'] + ['spell\-level1\-misc'] + r.F['spell\-level1\-specialist'] - r.I['cast\-value'];             return m;                      },{['cast\-value']: 0, desc []},function(m,r,a){             a.S['spell\-level1\-remaining'] = m['cast\-value'];         })         .execute(); }); This is my most recent attempt. I tried to escape the hyphens as I've determined them to be the problem (well, part of it, the other being that SimpleSum doesn't inherently seem capable of subtraction, but, I could be wrong there.)
So, I had a sort of success. I had to create a bunch of extra attributes to store the data in and then use autocalc fields to do the subtraction. Not ideal, but it works. on('change:repeating_spells', function(){          TAS.repeating('spells')         .attrs('spell-level1-integer1','spell-level1-sum1','spell-points1-spent-wiz1','total-arc1-spent')         .fields('cast-value','cast-max','spell-points1','arc1')         .reduce(function(m,r){             m['cast-value']+=(r.F['cast-value']);             r['spell-level1-integer1']=(r.F['cast-value']);             m['cast-max']+=(r.F['cast-max']);             r['spell-level1-sum1']=(r.F['cast-max']);             m['spell-points1']+=(r.F['spell-points1']);             r['spell-points1-spent-wiz1']=(r.F['spell-points1']);             m['arc1']+=(r.F['arc1']);             r['total-arc1-spent']=(r.F['arc1']);             return m;                      },{['cast-value']:0,['cast-max']:0,['spell-points1']:0,['arc1']:0, desc: []},function(m,r,a){             a['spell-level1-integer1']=m['cast-value'];             a['spell-level1-sum1']=m['cast-max'];             a['spell-points1-spent-wiz1']=m['spell-points1'];             a['total-arc1-spent']=m['arc1'];         })         .execute(); });