[Help] Sheet Worker Conditional

I'm trying to write a sheet worker script for whenever a character levels to level 10 (via the attribute @{Level}), it sets 1 as the attribute value for @{Level10}. But nothing I do is working correctly. This is what I have, and it's not affecting it any. I'm not even sure if I'm on the right path. Perhaps someone could steer me the right way? <script type="text/worker">     on("change:level ", function() {   getAttrs(["level"], function(values) {         if(values.level == '10' ){setAttrs({level10: 1)});} else       if(values.level == '<10' ){setAttrs({level10: 0) });}   }); }); </script>
1484107945
Brian
Pro
Sheet Author
API Scripter
Try this instead of your if-else: var level = parseInt(values.level); setAttrs({ level10: (level >= 10) | 0 });
Void that last message. Thanks for the help, it worked! I have a new question on a similar line of logic. How can I make it change the Status based on a number it's pulling from Fatal Damage? on("change:fataldamage" "sheet:opened", function() {   getAttrs(["fataldamage"], function(values) {         var level = parseInt(values.fataldamage); setAttrs({ status: (fataldamage <= 25) | "Stable" }); setAttrs({ status: (fataldamage >= 26||<= 50) | "Danger" }); setAttrs({ status: (fataldamage >= 51||<= 75) | "Critical" }); setAttrs({ status: (fataldamage >= 76||<= 99) | "Dying" }); setAttrs({ status: (fataldamage = 100) | "Dead" });   }); });
1484126796
Kryx
Pro
Sheet Author
on('change:fataldamage sheet:opened', function() { getAttrs(['fataldamage'], function(values) { var level = parseInt(values.fataldamage); if (level <= 25) { setAttrs({ status: 'Stable' }); } else if (level <= 50) { setAttrs({ status: 'Danger' }); } else if (level <= 75) { setAttrs({ status: 'Critical' }); } else if (level <= 99) { setAttrs({ status: 'Dying' }); } else if (level <= 100) { setAttrs({ status: 'Dead' }); } }); });
1484198181
Brian
Pro
Sheet Author
API Scripter
Heh, the "x | 0" construct I used is using the bitwise OR operator with 0, which is a fast way to convert something to an integer. A Boolean like "level >= 0" gets converted to 1 if true, and 0 if false.