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 .
×

Building custom sheet and can't link roll buttons to sheet abilities

Hello, I'm working on a first character sheet and having some issues with targeting sheet Abilities. What I want to do is have a button on a character's sheet that references/triggers an Ability on their sheet. In this example, I have a sheet button that I want to have trigger the "CarefulRoll" ability. The wiki shows an example using CharName, ie. "%{CharName|CarefulRoll}" - but this only works if I rename this character to be called "CharName". I want these buttons to work for all of my 4 player characters, each of whom will have the same Abilities on their sheets, regardless of their sheet names. However, just plain trying "%{CarefulRoll}" doesn't work either. How do I dynamically reference the current character? Here's the button code I've tried so far: (not sure name field really matters) 1. <button type='roll' value='%{CharName|CarefulRoll}'></button> 2. <button type='roll' name='roll_CarefulButton' value='%{CharName|CarefulRoll}'></button> 3. <button type='roll' value='%{CarefulRoll}'></button> 4. <button type='roll' name='roll_CarefulButton' value='%{CarefulRoll}'></button> 5. <button type='roll' value='%{attr_character_name|CarefulRoll}'></button> 6. <button type='roll' value="%{@{character_name}|CarefulRoll}"></button> Any suggestions? Thanks.
1563136466
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
So, there's a misunderstanding going on here. The buttons in the sheet html should never reference a custom ability on the attributes/abilities tab. Instead the roll buttons you put in the html are treated as abilities. You put the contents of the macro you want rolled from that button in the value attribute of the button element.
1563137002
GiGs
Pro
Sheet Author
API Scripter
That's an interesting problem. There is a way to do this, but before I illustrate how, i want to ask, why? Stuff in your custom sheet is hardcoded, it;s not easy to change. But abilities are easily changed, can be deleted, and might not even exist. So calling them from the character sheet is unreliable. It would be better to put whatever code you have in the ability, in the character sheet itself. Anyway, getting back to the issue: several of your attempts have bad syntax. The first two look fine, except you aren't using the correct name. You have three options. 1) use the character's actual name (not CharName). the above example, would be  <button type='roll' value='%{Test Char Friend|CarefulRoll}'></button> Obviously that's no good, since it will work for only one character.  2) use the selected keyword. <button type='roll' value='%{selected|CarefulRoll}'></button> This requires the character have a token, and the token be currently selected. This could be fine. If you dont want to use selected, and want to account for characters with different names (and who change their names) you need to use a sheet worker and a hidden attribute. In your html, the button code would be <input type='hidden' name='attr_carefullroll'/> <button type='roll' name='roll_CarefulRoll' value='@{carefullroll}'></button> And in your script block in the html: on("change:character_name sheet:opened", function () {     getAttrs(['character_name'],function(values) {           let name = values.character_name;         setAttrs({              carefullroll : '%{' + name + '| carefullroll }'         });     }); }); But again, if you explain what you want this ability to do, we can sugegst a way to include it in the character sheet instead. Linking an ability from the character sheet is just a bad idea.
"The buttons in the sheet html should never reference a custom ability on the attributes/abilities tab." "Linking an ability from the character sheet is just a bad idea." Ah, okay - so perhaps I was misled by the 'Building Character Sheets' wiki page talking about linking abilities. That's misleading if it's not intended. I follow that it would be bad practice for anything you want to release for others to use, but in my case I'm just building up some custom rules for a two-shot side game with some friends, and it seemed far cleaner for the code to reference an ability rather than shoving the ability details into the sheet code itself. So I should put my ability text entirely within the button node's value tag - got it. Thank you both! (The ability text isn't anything fancy, just a bunch of template text formatting stuff)
1563144430
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Jake said: Ah, okay - so perhaps I was misled by the 'Building Character Sheets' wiki page talking about linking abilities. That's misleading if it's not intended. I follow that it would be bad practice for anything you want to release for others to use, but in my case I'm just building up some custom rules for a two-shot side game with some friends, and it seemed far cleaner for the code to reference an ability rather than shoving the ability details into the sheet code itself. Are you talking about this: The names you give your Sheet Rolls must be unique from any Ability names on your Characters if you want to reference them in Abilities or Macros. You can also just not give your Sheet Rolls names if you just want them to only be rolled by clicking the button on the Sheet itself. This is simply pointing out that both sheet rolls and abilities are called with the same syntax.
This is where I got misled - now that I understand fully, I can see it's talking about using the 'name' parameter as a means for Abilities or Macros to link to the Sheet Roll and not generally about Ability References. I found the overall paragraph kind of confusingly written I guess. Combination of showing an example of the syntax that could be used to reference an Ability, lack of specification that you shouldn't do so even though you can, and some mentions of making use of references within Abilities that totalled together I found easy to misread as "references are good, here's how to do an Ability reference". I guess it's technically accurate, but I don't find it clear.