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

Link to Handout using API

March 31 (6 years ago)

Edited March 31 (6 years ago)
Rago
Pro

Is there any way to know the link to a handout using an API script?

Context: I have a personal database of treasures and I wrote a desktop software that read the database treasures and output it to an API script and the script, once runs, creates one handout for each Treasure, a Rollable Table and a Macro. When I run the macro, it draws randomly a treasure and shows, on chat, its name.

Is there any way, using the API script, to make the macro write the actual link to the treasure's handout instead just its name?

March 31 (6 years ago)
The Aaron
Roll20 Production Team
API Scripter

The url is constructable. I don’t remember it off the top of my head, but it’s somethkng like:

http://Roll20.net/handout/HANDOUT_ID

I’ll look it up and post back. 

March 31 (6 years ago)

Edited March 31 (6 years ago)
Rago
Pro

Thank. That's the missing part, build the handout url. - As far as I remember, with the url I can build the "[NAME](URL)" pattern to link it on chat.


Edit: Following the tip I'll try "http://journal.roll20.net/handout/<handout.id>"

With "handout" being the return from createObj('handout',....


Edit 2: The link seems to be this one above, but when running from macros the "[NAME](URL)" does not work... (paste on chat the same "[NAME](URL)" works).

March 31 (6 years ago)
The Aaron
Roll20 Production Team
API Scripter

Hmm... I just tried it in a macro and it worked.

[test](http://journal.roll20.net/handout/-KxPNKhi9xE_pB7e9BVd)

What does your macro look like?

March 31 (6 years ago)
Rago
Pro

This is my macro:

Drawing a random amulet: [[1t[Amulet]]]

And this is the only entry, for testing purposes, on Amulet table:

[Water Embodiment](http://journal.roll20.net/handout/-LbIpU_rhvZkoIR85O-Z)


It seems the the table roll is not subject to interpret the [NAME](URL) as I expected... rolling [[1t[Amulet]]] on chat results in:

[Water Embodiment](http://journal.roll20.net/handout/-LbIpU_rhvZkoIR85O-Z)
March 31 (6 years ago)
The Aaron
Roll20 Production Team
API Scripter

Right.  That's not an issue with the macro, it's an issue with Rollable Tables.  If you put the roll directly in chat, the result probably doesn't link either:

[[1t[Amulet]]]


You can use my RecurisveTable script to fix this: https://app.roll20.net/forum/post/5954076/script-update-recursivetables-now-with-rollable-table-images-and-better-prefixing-rules-for-roll-templates

Then just do:

!rt Drawing a random amulet: [[1t[Amulet]]]



March 31 (6 years ago)

Edited March 31 (6 years ago)
Rago
Pro

I thought RecurisveTable aim was to make a table roll using the result of another table roll, but it fixes that issue with tables too.

I have it installed on another session I play but on this one I'm developing a new game and I was instructed not to use another's script  if I intent to pack my game for distribution on future. (what makes sense, it would be steal other's work).

=\


March 31 (6 years ago)
Rago
Pro

Ok, I think I solved that - in a very ugly specific way, but it seems to work.

I made a small script with a !relink command.
On chat:message if it detects !relink at the start it searches for a single table roll... take it's result and replace by its name that is ín the format [LABEL](URL).


March 31 (6 years ago)
The Aaron
Roll20 Production Team
API Scripter

That certainly works.  

If you're hoping to make a Roll20 Module or Addon, you can't really rely on a script, sadly.

March 31 (6 years ago)

Edited March 31 (6 years ago)
Rago
Pro


The Aaron said:

That certainly works.  

If you're hoping to make a Roll20 Module or Addon, you can't really rely on a script, sadly.


Wait... that sentence may have more than one meaning.

Do you meant I can't even rely on my script? (please say my scripts are ok... please say my scripts are ok...)

March 31 (6 years ago)
The Aaron
Roll20 Production Team
API Scripter

Modules and Addons can be purchased by any subscription level, but API scripts can only be used by Pro subscribers.  Modules and Addons thus cannot rely on API scripts for their functionality.

March 31 (6 years ago)

Edited March 31 (6 years ago)
Rago
Pro

i got PRO almost when I meet Roll20, I forgot non-PRO has no access to API scripts...  Thanks for the reminder.


This is bad, no API means a big limitation since the Rollable Table is simply bad or bugged. (I'm not sure if the behavior or ignoring [LABEL](URL) is expected). Not being able to get the link of a random draw that has a related handout increases the time spend on searching for thing significantly.

Maybe I'll have to stick with the PDF book only, that is 90% done. =[

March 31 (6 years ago)
The Aaron
Roll20 Production Team
API Scripter

Probably the easiest thing to do would be to output a link to an appropriate alphabetical index handout along with the name.  Then at least they can get to it in 2 clicks. 

March 31 (6 years ago)
Rago
Pro

That seems to be a good approach; at least I can show a handout with only link of the same type of the random treasure rolled.