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

API calls inside standard character sheet fields

March 16 (3 years ago)

Hi everyone!  I was wondering if it's possible to add API calls or things like /fx inside normal character sheet fields.  I'm using the standard roll20 5e character sheet.

For example, on the PC character sheet there is the "Features & Traits" section.  Is it possible to put an API call inside of that so that when you click on it, it does whatever call I want. 

Another example is when an NPC attacks, can I put something in the attack description that will make it (for example) create an FX?

I know I can do all these things with macros, but I was curious is there was some way to get it working without macros.

March 16 (3 years ago)
GiGs
Pro
Sheet Author
API Scripter

This depends on the sheet you are using.

If you can put macros in the Features & Traits section, and click a button to run them, then the answer is yes. Otherwise the answer is no.

March 16 (3 years ago)

Well the first thing I did was actually try it rather than post on the forums, but I couldn't get it working.  That doesn't mean that it doesn't work though as it could work with some sort of trickery as there are lots of examples about that for other stuff on the forums.  Maybe I need to put in a special HTML escaping code to make it evaluate the command rather than spit it out as text, or it'll work great if I just install script X that makes Y happen...

The sheet I'm using is the standard "D&D 5e by Roll20" sheet.


March 16 (3 years ago)
GiGs
Pro
Sheet Author
API Scripter

I don't believe there's any trickery that'll make this particular ask work - whether API works is s entirely dependent on how the sheet is written. APIs usually require their text to be sent to chat in a specific way (on a separate line, with the ! at the start, with no extra characters inserted), and if the sheet isnt explicitly written to enable this, it won't work.

In addition, if the to-chat message uses any kind of rolltemplate, the extra processing performed by roll20 on the output kills any API attempts. And that's likely to be the situation in your case.

Using HTML escaping code wont help with any of these things.


One of Tim Maugh's scripts that intercept text sent to chat might be able to do something, but i'm not optimistic.

March 17 (3 years ago)

I'll poke around Tim Maugh's scripts and see if I can scrounge anything up, thanks!

March 17 (3 years ago)
GiGs
Pro
Sheet Author
API Scripter

Another approach - probably the most successful approach - is to bypass the sheet's buttons entirely. If you use a script like ScriptCards, you can make rolls that doe whatever you want.

It does make some of the sheet irrelevant, but sometimes that's the way you have to go.

March 17 (3 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

You can put API command buttons in most sheet fields:

[Command name}(!API call)


March 17 (3 years ago)
GiGs
Pro
Sheet Author
API Scripter

That's a good idea, but that means the button would have to be manually clicked. That;s not as useful if the user wants the API to be run instantly.

March 17 (3 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

GiGs: True, I was including it as an option.

Jim: You can also use the API script "Customizable Roll Listener". You can tell it a roll template and trigger terms and it will run an API command or macro when those conditions are filled. For instance, I have mine set to look for the words "[Ability] Saving Throw" in most 5e templates. When it encounters those words, it runs a macro that allows me to roll the appropriate saving throw for any selected token.

March 17 (3 years ago)
Andreas J.
Forum Champion
Sheet Author
Translator

keithcurtis said:

Jim: You can also use the API script "Customizable Roll Listener". You can tell it a roll template and trigger terms and it will run an API command or macro when those conditions are filled. For instance, I have mine set to look for the words "[Ability] Saving Throw" in most 5e templates. When it encounters those words, it runs a macro that allows me to roll the appropriate saving throw for any selected token.

See Customizable Roll Listener for instructions & examples on how to use it. I agree that it's probably a good solution for this.

March 17 (3 years ago)

Awesome, thanks everyone, I'll check that out!  As a software engineer I do so love automating manual tasks :)