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

Need help setting up code to have values equal other values.

February 28 (1 year ago)
Skyeris
Pro
Sheet Author

I'm not sure how to approach this part of the sheet. What I want is for a specific stat to display another stat.

Example: If I have Base AGI 5 I get 8 AP.

And of course I can add a modifier to adjust it incase I get bonuses from it. The stat is no longer determined by an equation. Below is the table I am wanting to setup to display on the sheet. Any help is appreciated.


February 28 (1 year ago)

Edited February 28 (1 year ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator

The best way to do this is to use a sheetworker that triggers when the attribute changes (assuming your abilities are ap, agi, and ap_bonus):

<script type='text/worker'>
on('change:agi change:ap_bonus',()=>{
  getAttrs(['agi','ap_bonus'],attributes => {
    const agi = +attributes.agi || 0;
    const ap_bonus = +attributes.ap_bonus || 0;

    const setObj = {};
    if(agi <= 5){
      setObj.ap = 8;
    }else if(agi <= 8){
      setObj.ap = 9;
    }else{
      setObj.ap = 10;
    }
    setObj.ap += ap_bonus;
    setAttrs(setObj);
  })
})
</script>

That would go at the bottom of your sheet code (if you already have sheetworkers, just put the js inside your existing script tag.

February 28 (1 year ago)
Skyeris
Pro
Sheet Author

This is exactly what I needed. Thank you so much!