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

Activating js with roll event

Hi,

can I activate js with a roll event button? And when exactly does it get executed?

Is this possible?:

 <button type="roll" name="act_test" value="[[@{mytext}]]"></button>

...

<script type="text/worker">

on("clicked:test", function () {
setAttr ({ mytext : "{{name=Dagger}} {{attack=1d20}} {{damage=1d6}}" });

I think i found the answer myself. It was pretty plain in the open.

https://wiki.roll20.net/Building_Character_Sheets#Sheet_Rolls_and_Roll_Buttons

Now I only have to fiddle for the right syntax :)

April 28 (5 years ago)
Wes
Pro
Sheet Author

You can activate the On:clicked with an type="action" button. Which does not send anything to chat.

April 28 (5 years ago)
Andreas J.
Forum Champion
Sheet Author
Translator

An action button can trigger sheetworkers, but rolls or roll buttons cannot. API Scripts could.

Either way, both custom character sheets and API scripts are Pro features only.

Are you sure? The reference i found is from the old wiki, so maybe that changed. I found nothing about this topic on the new site (the zendesk domain).


It would be of use in a general sheet, so API is no solution. My current user status should be of no interest.


Does the name attribute at least still exist? So I could access the roll with a macro?

April 28 (5 years ago)

Edited April 28 (5 years ago)
GiGs
Pro
Sheet Author
API Scripter

The reference you found is about roll buttons. With a roll button you can send to chat, but cannot activate sheet workers.

With an Action button, you can activate sheet workers, but you cannot send to chat.

These are fundamental limitations of the two button types, and you cannot bypass them.

The API is something different, and can do both of those, but requires a Pro subscription for the campaign's GM.


The reason people are mentioning your current status is because you look like a free user, and from time to time, free users dont realise they need Pro to use Custom Sheets or the API, so they are trying to help you out by letting you know this.

Peter said:

Does the name attribute at least still exist? So I could access the roll with a macro?

I'm not sure what you're asking for here.


Oh I got stucked in my own mind. Checked my own reference and all my open tabs in the browser... I obviously overlooked some stuff and got the wrong ideas. Thanks anyways!