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

Using Abilities in a Button for a Custom Character Sheet??

1472764023

Edited 1472822029
So after much head-banging and a complete failure of Google-fu, I need some help understanding using an ability inside of a character sheet. Here is the code snippet: <td> <div>CR:</div> <input type="number" title="CR" name="attr_CR" min=0 /> <div>MR:</div> <input type="number" title="MR" name="attr_MR" min=0 step=1 /> <button type="roll" value=" ??? " name=" YYY " title="Test Roll" /> </td> And here is the ability referenced The purpose is to call 3 API commands in order with no gaps. I know this can be done with assigning it to a macro or to 3 different buttons, but this is more of a learning exercise then just getting to work. Also, as the code behind those scripts is currently far from bulletproof, I don't want the players to actually know what those commands are. My questions are simply, what do I put in ??? and YYY in the code snippet. I have tried a handful of nesting commands and I cannot seem to get it right. I know that the chat needs to hear %{CharacterName|Roll_Test}, it seems the closest I can get is to have it hear {CharacterName|Roll_Test}. The moment I add the % , it gives a   "TypeError: Cannot read property 'substring' of undefined" error. Any help would be appreciated. (If it helps, this particular character's name is Okli Owim (randomly determined Roll20 name) and there is an attribute in the character sheet @{ID_Character} that stores the character's ID in it's current value. Assume that we are not using tokens, so no @{selected|.... or @{target|... Dan C.
1472798944

Edited 1472799051
Lithl
Pro
Sheet Author
API Scripter
<button type="roll" name="roll_example" value="%{Roll_Test}">Test Roll</button> ought to work. You could also use "!listplayers\n!listgm\n!listtokens" for value.
1472820900

Edited 1472821888
Brian, Thanks for the response. I tried adding it and I'm still getting the same "TypeError: Cannot read property 'substring' of undefined" error. Here is the code snippet (I added class="sheet-noinline" so it didn't mess with the rest of the formatting). I tried it two different ways (I prefer the <button ... /> option since there isn't supposed to be any text on the actual button, but that's just cosmetic...) As for inserting the actual function calls into the HTML, that I know that does work, but I'd rather not do it that way, simply because when I do finish the code that the is being called, the exact commands and flags will change and I'd rather save it in one place to edit later, rather than having to make the same correct a bunch of times in the HTML (unless you know of a way that Roll20 will allow for HTML code substitution??) <td> <div class="sheet-noinline">CR:</div> <input type="number" class="sheet-noinline" title="CR" name="attr_CR" min=0 /> <div class="sheet-noinline">MR:</div> <input type="number" class="sheet-noinline" title="MR" name="attr_MR" min=0 step=1 /> <button type="roll" class="sheet-noinline" value="%{Roll_Test}" name="roll_example" title="Test Roll" /> <button type="roll" class="sheet-noinline" name="roll_example" value="%{Roll_Test}">Test Roll</button> </td>
1472838878

Edited 1472838951
Lithl
Pro
Sheet Author
API Scripter
I can't test it myself at the moment, as I'm on a trip (sitting at my gate in SFO as I write this), but I'll try it out when I get home. If you don't want text on your button, the correct method is  <button></button>, not <button />; the button element is not a self-closing tag, although most browsers will close it for you. Roll20 will let you do the kind of substitution you're talking about via attributes: <input type="hidden" name="attr_text" value="foo bar"> <button type="roll" name="roll_ex1" value="@{text}"></button> <button type="roll" name="roll_ex2" value="/w GM @{text}"></button>
I did find a work around with that part of code substitution you mentioned. I don't know if it is supposed to work this way, but getting the value of the button to end up being %{character.id|Ability_Name} works. HTML: <input type="hidden" name="attr_Roll_Test_Text" value=""> <button type="roll" name="roll_Roll_Test" value="@{Roll_Test_Text}"></button> API: on("add:character": function(character) {     var roll_test_text = findObjs({_type: "attribute", name:"Roll_Test_Text", "_characterid": character.id})[0];     roll_test_text.set({'current': "%{"+character.id+"|Roll_Test}"});  });