I appreciate your help with this. I have inserted the script code into my sheet, changed all Roll Buttons to Action Buttons in both HTML and CSS. I added just the skill and ability names into some of the script but I'm not sure what else needs to be changed or added? Also I hope I understand you correctly. Will this change I make not work for buttons in a fieldset? Cause that is where attack rolls come from, inside a fieldset lol So far everything looks good but the buttons won't roll anything. This is what I have added to the script you made: // array that holds all the names of the skill buttons
const skills = ["genathletics", "gencovert", "gendomestic", "geninfluence", "genperception", "genpilot", "genscience", "genmelee", "genheavy", "genknow", "genmedical", "genmilitary", "genstarships", "gentech", "nature", "genranged", "climbing", "gym", "spo", "swim", "weight", "xspo", "conceal", "disguise", "escape", "forgery", "picklock", "pickpocket", "soh", "sneak", "streetsmart", "acting", "art", "cook", "dance", "dac", "mixology", "plantcare", "pmi", "sewing", "sing", "barter", "deception", "diplomacy", "empathy", "interrogation", "intimidation", "persuasion", "seduction", "detecttraps", "gambling", "gaming", "investigation", "sense", "surveillance", "aerovehicles", "aircraft", "watervehicles", "landvehicles", "detectambush", "detectconcealment", "dpa", "biology", "chemistry", "physics", "xenobio", "axes", "knives", "maces", "spears", "special", "staffs", "swords", "unarmed", "grenades", "heavyauto", "heavyrifle", "rocketlauncher", "throwerweapons", "bandits", "business", "cularbor", "culcouncil", "culouter", "culsector", "hisarbor", "hiscouncil", "hisouter", "hissector", "lawarbor", "lawcouncil", "lawouter", "lawsector", "relarbor", "relcouncil", "relouter", "relsector", "rememberinfo", "firstaid", "forensics", "pathology", "psychiatry", "surgery", "toxicology", "xenopathology", "armourer", "blacksmith", "demolitions", "findcont", "gunsmith", "militaryknowledge", "womd", "xenoweapons", "starshipeng", "starshipgen", "starshipnav", "spl", "sps", "starshiprepair", "sss", "starshipweapons", "advancedfirearms", "bbss", "comsystems", "computers", "electronics", "mechanics", "robotics", "fishing", "fauna", "flora", "landnav", "trackanimals", "trapping", "wac", "wildernesssurvival", "xenoanimalcare", "automaticrifles", "bows", "longrangerifles", "pistols", "shotguns", "submachineguns", "thrownweapons"];
skills.forEach(skill => {
// listen for the click on each button
on(`clicked:${skill}`,() => {
// create an array of attribute names to get with getAttrs
// I'd just put all the attribute names that you might need for any skill roll in here. This demo just has the ones for your disguise roll
const getArr = ["genathletics", "gencovert", "gendomestic", "geninfluence", "genperception", "genpilot", "genscience", "genmelee", "genheavy", "genknow", "genmedical", "genmilitary", "genstarships", "gentech", "nature", "genranged", "climbing", "gym", "spo", "swim", "weight", "xspo", "conceal", "disguise", "escape", "forgery", "picklock", "pickpocket", "soh", "sneak", "streetsmart", "acting", "art", "cook", "dance", "dac", "mixology", "plantcare", "pmi", "sewing", "sing", "barter", "deception", "diplomacy", "empathy", "interrogation", "intimidation", "persuasion", "seduction", "detecttraps", "gambling", "gaming", "investigation", "sense", "surveillance", "aerovehicles", "aircraft", "watervehicles", "landvehicles", "detectambush", "detectconcealment", "dpa", "biology", "chemistry", "physics", "xenobio", "axes", "knives", "maces", "spears", "special", "staffs", "swords", "unarmed", "grenades", "heavyauto", "heavyrifle", "rocketlauncher", "throwerweapons", "bandits", "business", "cularbor", "culcouncil", "culouter", "culsector", "hisarbor", "hiscouncil", "hisouter", "hissector", "lawarbor", "lawcouncil", "lawouter", "lawsector", "relarbor", "relcouncil", "relouter", "relsector", "rememberinfo", "firstaid", "forensics", "pathology", "psychiatry", "surgery", "toxicology", "xenopathology", "armourer", "blacksmith", "demolitions", "findcont", "gunsmith", "militaryknowledge", "womd", "xenoweapons", "starshipeng", "starshipgen", "starshipnav", "spl", "sps", "starshiprepair", "sss", "starshipweapons", "advancedfirearms", "bbss", "comsystems", "computers", "electronics", "mechanics", "robotics", "fishing", "fauna", "flora", "landnav", "trackanimals", "trapping", "wac", "wildernesssurvival", "xenoanimalcare", "automaticrifles", "bows", "longrangerifles", "pistols", "shotguns", "submachineguns", "thrownweapons", 'agility_dice', 'strength_dice', 'alertness_dice', 'endurance_dice', 'mind_dice', 'charisma_dice'];
// get the attribute values. Note the async tag on the callback function. This will allow us to use await with the startRoll sheetworker.
getAttrs(getArr,async (attributes) => {
// process the skill name into it's plain text name
const textName = capitalize(skill.replace(/-+|_+/g,' '));
// ask the user what dice pool they want to use
const abilityName = await extractQueryResult('Select Ability|None,none|Strength,strength|Agility,agility,Alertness,alertness|Endurance,endurance|Mind,mind|Charisma,charisma');
// get the dice value to use
const abilityDice = attributes[abilityName] || '0';
// decide whether to append the cs/cf customization to it
const modifiedAbilityDice = abilityDice === '0' || /d20/.test(abilityDice) ?
attributes[abilityName] :
`${attributes[abilityName]}cs<0cf<0`;
// create the text that is going to be sent to chat
const rollText = `@{whispertoggle}&{template:custom}{{title=@{character_name}}} {{Roll=[[d0 + ${modifiedSkillDice} + ${modifiedAbilityDice}]] | [[d0 + ${modifiedSkillDice} + ${modifiedAbilityDice}]]}} {{desc2=**${textName} check**}} {{status= }} @{blind} @{burning} @{charmed} @{chilled} @{deafened} @{distracted} @{drained} @{frightened} @{frozen} @{incapacitated} @{paralyzed} @{poisoned} @{prone} @{restrained} @{stunned} @{unconscious}`;
const roll = await startRoll(rollText);
finishRoll(roll.rollId);
})
})
});
// function to allow us to query the user for information
const extractQueryResult = async function(query){
const rollObj = {
query:`[[0[response=?{${query}}]]]`
};
const msg = `{{query=[[0[response=?{${query}}]]]}}`;
const roll = await startRoll(msg);
finishRoll(roll.rollId);
return roll.results.query.expression.replace(/^.+?response=|\]$/g,'');
};
// capitalize function pulled from the K-scaffold
const capitalize = function(string){
return string.replace(/(?:^|\s+|\/)[a-z]/ig,(letter)=>letter.toUpperCase());
}; This is what the rest of my sheetworker looks like if that is necessary: <!-- SHEETWORKER -->
<script type="text/worker">
// Script that does something I don't understand
const int = score => parseInt(score, 10) || 0;
// Script work for Attributes (uses the word stat)
const stat = ["strength", "agility", "alertness", "endurance", "mind", "charisma"];
stat.forEach(stat => {
on(`change:${stat}`, () => {
getAttrs([stat], values => {
const stat_points = int(values[stat]);
console.log(stat_points);
let stat_dice = "0";
if (stat_points >= 30) stat_dice = "d12 + d10";
else if (stat_points >= 29) stat_dice = "d12 + d8";
else if (stat_points >= 28) stat_dice = "d12 + d8";
else if (stat_points >= 27) stat_dice = "d12 + d6";
else if (stat_points >= 26) stat_dice = "d12 + d6";
else if (stat_points >= 25) stat_dice = "d12 + d4";
else if (stat_points >= 24) stat_dice = "d12 + d4";
else if (stat_points >= 23) stat_dice = "d12 + d2";
else if (stat_points >= 22) stat_dice = "d12 + d2";
else if (stat_points >= 21) stat_dice = "d12";
else if (stat_points >= 20) stat_dice = "d12";
else if (stat_points >= 19) stat_dice = "d10";
else if (stat_points >= 18) stat_dice = "d10";
else if (stat_points >= 17) stat_dice = "d8";
else if (stat_points >= 16) stat_dice = "d8";
else if (stat_points >= 15) stat_dice = "d6";
else if (stat_points >= 14) stat_dice = "d6";
else if (stat_points >= 13) stat_dice = "d4";
else if (stat_points >= 12) stat_dice = "d4";
else if (stat_points >= 11) stat_dice = "d2";
else if (stat_points >= 10) stat_dice = "d2";
else if (stat_points >= 9) stat_dice = "-d2";
else if (stat_points >= 8) stat_dice = "-d2";
else if (stat_points >= 7) stat_dice = "-d4";
else if (stat_points >= 6) stat_dice = "-d4";
else if (stat_points >= 5) stat_dice = "-d6";
else if (stat_points >= 4) stat_dice = "-d6";
else if (stat_points >= 3) stat_dice = "-d8";
else if (stat_points >= 2) stat_dice = "-d8";
else if (stat_points >= 1) stat_dice = "-d10";
else stat_dice = "0";
setAttrs({
[`${stat}_dice`]: stat_dice
});
});
});
});
// Script work for skills (uses the word skill)
const skill = ["genathletics", "gencovert", "gendomestic", "geninfluence", "genperception", "genpilot", "genscience", "genmelee", "genheavy", "genknow", "genmedical", "genmilitary", "genstarships", "gentech", "nature", "genranged", "climbing", "gym", "spo", "swim", "weight", "xspo", "conceal", "disguise", "escape", "forgery", "picklock", "pickpocket", "soh", "sneak", "streetsmart", "acting", "art", "cook", "dance", "dac", "mixology", "plantcare", "pmi", "sewing", "sing", "barter", "deception", "diplomacy", "empathy", "interrogation", "intimidation", "persuasion", "seduction", "detecttraps", "gambling", "gaming", "investigation", "sense", "surveillance", "aerovehicles", "aircraft", "watervehicles", "landvehicles", "detectambush", "detectconcealment", "dpa", "biology", "chemistry", "physics", "xenobio", "axes", "knives", "maces", "spears", "special", "staffs", "swords", "unarmed", "grenades", "heavyauto", "heavyrifle", "rocketlauncher", "throwerweapons", "bandits", "business", "cularbor", "culcouncil", "culouter", "culsector", "hisarbor", "hiscouncil", "hisouter", "hissector", "lawarbor", "lawcouncil", "lawouter", "lawsector", "relarbor", "relcouncil", "relouter", "relsector", "rememberinfo", "firstaid", "forensics", "pathology", "psychiatry", "surgery", "toxicology", "xenopathology", "armourer", "blacksmith", "demolitions", "findcont", "gunsmith", "militaryknowledge", "womd", "xenoweapons", "starshipeng", "starshipgen", "starshipnav", "spl", "sps", "starshiprepair", "sss", "starshipweapons", "advancedfirearms", "bbss", "comsystems", "computers", "electronics", "mechanics", "robotics", "fishing", "fauna", "flora", "landnav", "trackanimals", "trapping", "wac", "wildernesssurvival", "xenoanimalcare", "automaticrifles", "bows", "longrangerifles", "pistols", "shotguns", "submachineguns", "thrownweapons"];
skill.forEach(skill => {
on(`change:${skill}`, () => {
getAttrs([skill], values => {
const skill_points = int(values[skill]);
console.log(skill_points);
let skill_dice = "0";
if (skill_points >= 10) skill_dice = "d12+d8";
else if (skill_points >= 9) skill_dice = "d12+d6";
else if (skill_points >= 8) skill_dice = "d12+d4";
else if (skill_points >= 7) skill_dice = "d12+d2";
else if (skill_points >= 6) skill_dice = "d12";
else if (skill_points >= 5) skill_dice = "d10";
else if (skill_points >= 4) skill_dice = "d8";
else if (skill_points >= 3) skill_dice = "d6";
else if (skill_points >= 2) skill_dice = "d4";
else if (skill_points >= 1) skill_dice = "d2";
else if (skill_points >= 0) skill_dice = "0";
else if (skill_points >= -1) skill_dice = "-d2";
else if (skill_points >= -2) skill_dice = "-d4";
else if (skill_points >= -3) skill_dice = "-d6";
else if (skill_points >= -4) skill_dice = "-d8";
else if (skill_points >= -5) skill_dice = "-d10";
else if (skill_points >= -6) skill_dice = "-d12";
else if (skill_points >= -7) skill_dice = "-d12-d2";
else if (skill_points >= -8) skill_dice = "-d12-d4";
else if (skill_points >= -9) skill_dice = "-d12-d6";
else if (skill_points >= -10) skill_dice = "-d12-d8";
else skill_dice = "0";
setAttrs({
[`${skill}_dice`]: skill_dice
});
});
});
});
on("change:classname", function() {
console.log("Set ClassCheck = ClassName if not already equal.")
getAttrs(["ClassName","ClassCheck"], function(values) {
if (values.ClassCheck !== values.ClassName) {
setAttrs({ ClassCheck: values.ClassName });
};
});
console.log("ClassCheck = ClassName whenever changed.");
});
on("change:npcclassname", function() {
console.log("Set npcClassCheck = npcClassName if not already equal.")
getAttrs(["npcClassName","npcClassCheck"], function(values) {
if (values.npcClassCheck !== values.npcClassName) {
setAttrs({ npcClassCheck: values.npcClassName });
};
});
console.log("npcClassCheck = npcClassName whenever changed.");
});