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

I can't understand why this sheetworker IF statement doesn't work

on("change:encumbrload", function() { getAttrs(["encumbrload","encumbrmaxdexhidden","encumbracphidden","encumbrspeedhidden","encumbrrunhidden"], function(values) { const encumbrload = parseFloat(values.encumbrload) let encumbrmaxdexhidden let encumbracphidden let encumbrspeedhidden let encumbrrunhidden if (encumbrload = 1) { encumbrmaxdexhidden=20; encumbracphidden=0; encumbrrunhidden=4; } else if (encumbrload = 0.67) { encumbrmaxdexhidden=3; encumbracphidden=-3; encumbrrunhidden=4; } else { encumbrmaxdexhidden=1; encumbracphidden=-6; encumbrrunhidden=3; } setAttrs({ encumbrmaxdexhidden, encumbracphidden, encumbrrunhidden}); }); }); encumbrload is a dropdown with only 3 values (1, 0.67, 0.667) this function doesn't break my sheet so something is right about it? I've tried for a while and cant seem to get it working... I think I'm messing up the setAttrs? I'm just about done automating the encumbrance section of the 3.5 character sheet. After this I need to compare these printed values with the values placed from the armor and shield section and print the highest number. I'm so close if anyone has an
1723691230

Edited 1723713542
GiGs
Pro
Sheet Author
API Scripter
Your if statement should not be using equals, it should be using == or ===. In JavaScript, an equals sign says, "set to this value" and can't be used to check if something is some value. So try if (encumbrload === 1) { encumbrmaxdexhidden=20; encumbracphidden=0; encumbrrunhidden=4; } else if (encumbrload === 0.67) {
Oh my god, I spent 2 hours flipping through every combination and way of writing this thing! Bet it not gonna forget that information now!
1723693190
GiGs
Pro
Sheet Author
API Scripter
not gonna forget that information now If only it were that easy! I still make this mistake, hehe.