I got a script that works out the mod for a score using if statment but its getting really long and has a cap to it
const stats = ["melee","ranged","str","con","per","move","ste","fin","cont","cha","ter","int","wit","tin"];
stats.forEach(stat => {
on(`change:${stat}`, () => {
getAttrs([stat], values => {
const stat_base = int(values[stat]);
console.log(stat_base);
let stat_bonus = 0;
if (stat_base <=1) stat_bonus = "-5";
else if (stat_base <=3) stat_bonus = "-4";
else if (stat_base <=5) stat_bonus = "-3";
else if (stat_base <=7) stat_bonus = "-2";
else if (stat_base <=9) stat_bonus = "-1";
else if (stat_base <=11) stat_bonus = "0";
else if (stat_base <=13) stat_bonus = "1";
else if (stat_base <=15) stat_bonus = "2";
else if (stat_base <=17) stat_bonus = "3";
else if (stat_base <=19) stat_bonus = "4";
else if (stat_base <=21) stat_bonus = "5";
else if (stat_base <=23) stat_bonus = "6";
else if (stat_base <=25) stat_bonus = "7";
else if (stat_base <=27) stat_bonus = "8";
else if (stat_base <=29) stat_bonus = "9";
else if (stat_base <=31) stat_bonus = "10";
else if (stat_base <=33) stat_bonus = "11";
else if (stat_base <=35) stat_bonus = "12";
else if (stat_base <=37) stat_bonus = "13";
else if (stat_base <=39) stat_bonus = "14";
else if (stat_base <=41) stat_bonus = "15";
else if (stat_base <=43) stat_bonus = "16";
else if (stat_base <=45) stat_bonus = "17";
else if (stat_base <=47) stat_bonus = "18";
else if (stat_base <=49) stat_bonus = "19";
else if (stat_base <=51) stat_bonus = "20";
else if (stat_base <=53) stat_bonus = "21";
else if (stat_base <=55) stat_bonus = "22";
else if (stat_base <=57) stat_bonus = "23";
else if (stat_base <=59) stat_bonus = "24";
else if (stat_base <=61) stat_bonus = "25";
else if (stat_base <=63) stat_bonus = "26";
else if (stat_base <=65) stat_bonus = "27";
else if (stat_base <=67) stat_bonus = "28";
else if (stat_base <=69) stat_bonus = "29";
else if (stat_base <=71) stat_bonus = "30";
else if (stat_base <=73) stat_bonus = "31";
else if (stat_base <=75) stat_bonus = "32";
else if (stat_base <=77) stat_bonus = "33";
else if (stat_base <=79) stat_bonus = "34";
else if (stat_base <=81) stat_bonus = "35";
else if (stat_base <=83) stat_bonus = "36";
else if (stat_base <=85) stat_bonus = "37";
else if (stat_base <=87) stat_bonus = "38";
else if (stat_base <=89) stat_bonus = "39";
else if (stat_base <=91) stat_bonus = "40";
else if (stat_base <=93) stat_bonus = "41";
else if (stat_base <=95) stat_bonus = "42";
else if (stat_base <=97) stat_bonus = "43";
else if (stat_base <=99) stat_bonus = "44";
else if (stat_base <=101) stat_bonus = "45";
else if (stat_base <=103) stat_bonus = "46";
else if (stat_base <=105) stat_bonus = "47";
else if (stat_base <=107) stat_bonus = "48";
else if (stat_base <=109) stat_bonus = "49";
else if (stat_base <=111) stat_bonus = "50";
else if (stat_base <=113) stat_bonus = "51";
else if (stat_base <=115) stat_bonus = "52";
else if (stat_base <=117) stat_bonus = "53";
else stat_bonus = "error"
setAttrs({
[`${stat}_bonus`]: stat_bonus
});
});
});
});
so i was wondering if i could do something like it after the base stat is 12 or bigger it would take away 10 from the the base stat then divide it by 2 then round down and set that as the stat bonus