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

[Custom Sheet] Making condition-based value for attributes

Hello dear people of roll20, i hope you have a good day on those panic-filled times. I make my first post since i first came to roll20 because recently, i've update my subscription to a pro one in attempt to make my own Character Sheet for my game. I'm using a Homebrew game, based (at first) on Basic RPG. Here's the deal, i can handle HTML and CSS (had to remember what i knew from, like, 10 years ago), but to give the most confort to my players, i'm trying to automate things a little. First thing first, i have some value that gets into a table and give another value. Here some example :  1 - If your Sta (stamina) is less than 12, you regenerate 1HP every 2 days, if it's between 12 and 16, you get 1hp every day, and if it's above 17 you get 2hp every day.  2 - If the sum of your Str (strenght) and Siz (Size) is less than 19, you get no Attack Bonus. If it's between 19 and 21, it's 1 Attack Bonus, 22 and 24, 2 and above 25 it's 3. So i've got those attributes : Sta, Str, Siz, and for the secondaries : Hp_regen, Attack_bonus, and i've been wanting to change their value depending of one another, and be able to put them in display on my Sheet, as well as using those values (especially Attack_bonus) on my weapons roll. Thing is, i want those secondaries to be able to update themselves whenever Sta, Str and Siz changes. I get that i need to use the Sheet Worker (even tho i don't really understand how it works) and use getAttrs and setAttrs, but i have no idea how it works. So i'm requesting help, please, to solve my problem. I hope you'll be able to enlighten me, and that you have fun with your games ^^ (btw, if someone who knows how to do that is french, don't bother writting in english, i'm french myself x])
1584713022

Edited 1584713043
Check some of the guides and examples aimed to beginners . They explain things better than the default Sheetworker page. Also, steal code form existing sheets and play around.
1584713613

Edited 1584717165
Haha yeah already stealing x] I'm kinda retro-engineering things to work, but i'm stuck with a code not working. Thanks for the link, i.... somehow didn't found that section in the wiki x] Ok so now, i struggle with something else, and i'm currently searching the wiki but i doesn't really help. So my script is like that. on("change:con change:con_temp change:con_modif change:con_base", function() { getAttrs(['con', "con_temp", "con_modif", "con_base", "pv_regen"], function(v) { var pv_regen = 0; if(v[ 'con' ] < 12)  { pv_regen = 0.5; } else if(v[ 'con' ] >= 17)  { pv_regen = 2; } else { pv_regen = 1; } setAttrs({ "pv_regen": pv_regen }); }); }); My character's con ( it's the stamina) is 8, but it gives me the "else", thus resulting in a 1 where it should be 0.5. I've tried putting an else if instead of else... else if(v[ "con" ] < 17, v[ "con" ] >= 12) { pv_regen = 1; } But it doesn't change anything... Any clue? I clearly think my if else is not done right but i don't know what's wrong with it....
1584730795
Andreas J.
Forum Champion
Sheet Author
Translator
Maybe the function somehow round up the number to 1? Try change the "pv_regen = 0.5;" to "pv_regen = 3;" to test my hypothesis.