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 Script] Not working as intended could use help fixing

1609037957
Michael I.
Pro
Sheet Author
This code below is what I am currently working with, the current problem is if I place a number into  unused_experience_points and hit enter it sums up  unused_experience_points and used_experience_points and enters a value for total_experiance_points this is as intended, however if I place a number into used_experiance_points and hit enter the number gets entered into the attribute however it is not updating total_experiance_points, so I am not seeing why its not summing unused_experience_points and used_experience_points and is not entering a value for total_experiance_points if I am entering the number in used_experience_points, as far as I can tell it should be updating on change. so could use some extra eyes to help me figure this out. Code Below: on("change:unused_experience_points change:used_experience_points:opened", function() { getAttrs(["unused_experience_points","used_experience_points"], function(values) { let unusedexperiencepoints = parseInt(values.unused_experience_points,10)||0; let usedexperiencepoints = parseInt(values.used_experience_points,10)||0; let totalexperiencepoints = unusedexperiencepoints + usedexperiencepoints; setAttrs({ total_experience_points: totalexperiencepoints }); }); });
1609039618
GiGs
Pro
Sheet Author
API Scripter
it looks like youve probably made a cut & paste error at some point. This line on("change:unused_experience_points change:used_experience_points:opened", function() { should be on("change:unused_experience_points change:used_experience_points sheet:opened", function() {
1609044498
Michael I.
Pro
Sheet Author
Thanks you GiGs, That indeed was it. 
1609048830
GiGs
Pro
Sheet Author
API Scripter
Great :)