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

Wrote my first Character Sheet and Button - how to make the Button a Token action?

Heya. Just took the plunge and upgraded, created my first character sheet (for ROSD, simple as chips). I have a button set up, c'est ca:  <button name="roll_fight" type="roll" value="&{template:default} {{name=Fight for @{character_name} }}  {{Result=[[d20+(@{fight})]]}}"></button> Which works peachy! Now, before I did this, we had macros like this:  Roll for @{selected|token_name} /roll 1d20 + @{selected|fight} for each token (basically, each player gets a 5-man warband) How do I set a token action macro to press the button for the selected token please? I'm aware this is probably a n00b question! :) Cheers
1602339600

Edited 1602344656
Andreas J.
Forum Champion
Sheet Author
Translator
That is a good question. I think I remember it should be possible to make sheet buttons hard-coded to show up as token actions, but that it's generally not recommended, so not done too often. Surprisingly enough, I didn't manage to find any documentation on how it's done, nor find any examples from the repo on a quick search, so think we need to wait for others to come with answers. This is definitively going to be added to the <a href="https://wiki.roll20.net/Button" rel="nofollow">https://wiki.roll20.net/Button</a> page on how sheet buttons are made. Edit: On second thought, I'm starting to doubt myself if this is possible at all, as I didn't find any sheet that seemed to do something like this, maybe I'm just remembering something related to macros and the token bars?
Thanks! It seems extremely obvious as a desirable, especially for things like D&amp;D Initiative where you don't want to have to trudge through opening your character just to roll it. Seems pointless having the button if you can't
1602345288
Andreas J.
Forum Champion
Sheet Author
Translator
But if you give your roll buttons names starting with a "roll_", it makes it possible to call with a sheet attribute roll " %{rollname} ", so if that's saved to a token action, I think it could work right away. And those named character sheet buttons can be dragged &amp; dropped to your quick macro bar , but are then ofc tied to roll for that specific character.
1602347999

Edited 1602348042
Andreas J.
Forum Champion
Sheet Author
Translator
Scott C. reminded me that Diana P.'s " D&amp;D 3.5 " sheet have an example of this, where the initiative button is hardcoded as a token action. You do that by giving the button class="tokenaction" . Searching for that in the repo gives a couple of more examples.
1602355063
GiGs
Pro
Sheet Author
API Scripter
As Andreas suggested earlier, you absolutely do not want to do this . Token actions created from the sheet are forced on the user, and have a fixed location in the order, and users have no ability to control whether those token actions appear or not.&nbsp; People have used this feature in the past, and it has only met negative criticism when used. Players who are happy with the token actions you choose, can easily add them themselves (create a macro or ability to roll the button, and tick the box to make it a token action). But people who don't want them, or want control over the order they appear and what they are named, are out of luck. They can do nothing to stop any token actions you create from appearing, and cannot change their name or appearance. Many people have limited screen space, so want to choose carefully which token actions actually appear. Don't take the control away from them.
1602355816

Edited 1602355837
Andreas J.
Forum Champion
Sheet Author
Translator
GiGs said: Token actions created from the sheet are forced on the user, and have a fixed location in the order, and users have no ability to control whether those token actions appear or not.&nbsp; Do you think it would be possible to make it optional, or to toggle on/off whether a button is one or not? I'd assume it's probably not possible or someone would have figured it out already. But if you'd have two otherwise identical button where one have have the class and the other doesn't, and then throught some clever CSS/sheetworker stuff disable/enable them? GiGs , while were talking obscure features few know or use, can you share some other lesser know fact that most don't know about?(So I can document both) Maybe we rest can learn/be reminded of something else that isn't documented anywhere. Is it possible to hardcode into sheets which attributes, if any, are linked by default to which token bar? (I know that can be done for compendium-dropped characters, but that doesn't work the same.)
1602356749
GiGs
Pro
Sheet Author
API Scripter
📜🗡Andreas J.🏹📜 said: GiGs said: Token actions created from the sheet are forced on the user, and have a fixed location in the order, and users have no ability to control whether those token actions appear or not.&nbsp; Do you think it would be possible to make it optional, or to toggle on/off whether a button is one or not? I'd assume it's probably not possible or someone would have figured it out already. But if you'd have two otherwise identical button where one have have the class and the other doesn't, and then throught some clever CSS/sheetworker stuff disable/enable them? This is the reason no one uses this feature. It is not possible to affect these token actions in any way - you cant toggle them on/off. Regarding your idea of using a class to toggle visibility - I think &nbsp;this has been tested, but I cant remember. It's worth trying out. My gut feeling is that the token actions will appear regardless of the buttons visibility in the sheet, and in your example, users would end up with two token action buttons. Not idea! Regarding tokenbars - no, thats not possible. Character sheets have no way to interact with tokens. Character sheet code operates only on the character sheet, and nothing outside of it. The compendium is different because it exists outside the sheet, and has been programmed to be 'aware' of both sheets and tokens. It would be very nice to have that ability on character sheets, but my impression is that the roll20 devs are happy for that to remain in the province of the API, and thus a Pro subscriber feature.
1602357280

Edited 1602358129
Andreas J.
Forum Champion
Sheet Author
Translator
GiGs said: Regarding your idea of using a class to toggle visibility - I think &nbsp;this has been tested, but I cant remember. It's worth trying out. My gut feeling is that the token actions will appear regardless of the buttons visibility in the sheet, and in your example, users would end up with two token action buttons. Not idea! display: none; doesn't work, as you suspected, the token action still shows up. Anyway, it could be useful in games where the GM makes active changes to the sheet between and during sessions, it could be useful in a session or two, but be fairly situational. Some kind of war games where sheets have little use and you have few stats, it might be useful for new tokens have the few roll buttons appear when selected with out having to configure things or basically not use the sheet at all. Very situational, in any case.
This is the reason no one uses this feature. It is not possible to affect these token actions in any way - you cant toggle them on/off. Very much incorrect. None of my players has the least interest in writing or arranging their own macros or buttons. They want me to do it for them, and as the only trained programmer in the group as well as the DM that works for everyone. The addition of Pro to get character sheets is for us a method of improving token actions, not the other way around. If people have limited screen space, the last thing they want is to have to have their character sheet open all the time I would think... But if you give your roll buttons names starting with a "roll_", it makes it possible to call with a sheet attribute roll " %{rollname} ", so if that's saved to a token action, I think it could work right away. I've tried this but can't get it to work. They already do have such names, being copied from the example sheets. How exactly do I call that though? I created a macro with that in the body and it comes up with&nbsp;No ability was found for %{@selected|roll_fight} Even though it's not something that suits your game, this would be dead useful to me, so I'd be really grateful for some help to get it working! Thanks
1602359687
GiGs
Pro
Sheet Author
API Scripter
If the sheet is just for your group, and your players want it, go for it. Just try not to go overboard - keep the number of forced tokenactions low. Regarding your other issue, the syntax for this has two errors: %{@selected|roll_fight} It should be %{selected|fight} The roll_ part of a button name is like the attr_ part of an attribute name. It's not actually part of the name - its a flag to let the roll20 system know what kind of name this is, and to treat it accordingly. But when users use them using the @{} or %{} syntax, those parts get dropped.
If the sheet is just for your group, and your players want it, go for it. Just try not to go overboard - keep the number of forced tokenactions low. Bingo! Works a treat. Thanks for your help! :)
1602360280
GiGs
Pro
Sheet Author
API Scripter
Great!