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 here.
×
×
Cookie Preferences
We use Cookies to help personalize and improve Roll20. For more information on our use of non-essential Cookies, visit our Privacy Policy here.
in what context? in a macro that a roll button is sending? That's not possible. Or if you mean in the sheetworker to drive the sheet, it's just basic javascript code. Can you share the code that is giving you issues? Edit: Here's a basic javascript if/else: if(value < 1){
setAttrs({affected_attribute:0}); }else if(value > 3){
setAttrs({affected_attribute:value*2});
}else{
setAttrs({affected_attribute:value});
} and a basic for loop (note that personally I avoid for loops like the plague): let v = 0;
for(let i = 0;i<4;i++){
v+= (i + 1)*2;
}
Skyeris said: How would you insert the script in the sheet? <a href="https://wiki.roll20.net/Building_Character_Sheets#Sheet_Workers_Scripts" rel="nofollow">https://wiki.roll20.net/Building_Character_Sheets#Sheet_Workers_Scripts</a>
You insert code in the html code using the script tag: <script type='text/worker'>
//Code here
</script> only use ONE script tag. All your code goes in that single script tag. The script tag can be anywhere in your code, but common practice is to put it at the end of the html. I'd recommend reading the building character sheets and sheetworkers wiki pages. Edit: Also, note that my proto code above will do pretty much nothing (except possibly trigger an error in the console) as it lacks any listener context or other necessary pieces of a functional sheetworker.
If you stat what specifically you want to happen, (like, for example, "I want to change their bloodied status attribute when hit points drop below half"), we can give specific tips that are a lot more helpful.