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

Sheetworker...extra eyes needed

July 26 (5 years ago)
Ray
Pro

My sheetworker is as follows...

    on('change:crowns change:pennies change:farthings sheet:opened', function () {

        getAttrs(['crowns'], function(v) {

            const crowns = v.crowns *1||0;

            const pennies = v.pennies *1||0;

            const farthings = v.farthings *1||0;

            const crowns_wgt = crowns/16;

            const pennies_wgt = pennies/128;

            const farthings_wgt = farthings/512;

            const coins_wgt = crowns_wgt + pennies_wgt + farthings_wgt;

            setAttrs({

                 crowns_wgt: crowns_wgt,

                 pennies_wgt: pennies_wgt,

                 farthings_wgt: farthings_wgt,

                 coins_wgt: coins_wgt

            });

        });

    });

I am getting the following result...

So...the error is that the "pennies_wgt" and "farthings_wgt" are not being calculated.

Can anyone see why?

July 26 (5 years ago)
GiGs
Pro
Sheet Author
API Scripter

Change this line

 getAttrs(['crowns'], function(v) {

to

 getAttrs(['crowns','pennies','farthings'], function(v) {

PS: you can format text as code like this by looking at the post format bar - where it has B I U etc. The very left button is a dropdown, and Code is an option.


July 26 (5 years ago)
Ray
Pro

Ok...disregard this problem, I found the error...

getAttrs(['crowns','pennies','farthings'], function(v) {

July 26 (5 years ago)
Ray
Pro


GiGs said:

Change this line

 getAttrs(['crowns'], function(v) {

to

 getAttrs(['crowns','pennies','farthings'], function(v) {

PS: you can format text as code like this by looking at the post format bar - where it has B I U etc. The very left button is a dropdown, and Code is an option.

Awwww...you beat me to it GiGs...LOL


July 26 (5 years ago)

Edited July 26 (5 years ago)
Wes
Sheet Author

In the getAttrs you are only getting the "crowns" attribute.

    getAttrs(['crowns', 'pennies', 'farthings'], function(v) {


Edit: sniped while getting coffee.....