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

[Request] Auto-linking from drag and drop characters

I've already built a bunch of API scripts for my campaign to automate repetitive tasks. Currently, I'm trying to build a script to automatically set up all the stats on a new token when I drag and drop it from my list of characters. I already have something similar to the script to set token defaults . However, I can't get it to handle some of the tasks I would like. Current (manual) process steps: 1) Drag a character sheet from the journal to the map (it creates the token) 2) Edit the token to set the "represents" field back to the same character sheet 3) Edit bar1 to link it to the character sheet's "hp" field 4) Edit bar1 (again) to UNLINK it from the character sheet's "hp" field (so it won't link back for generic bad guys) 5) Edit bar3 to link it to the character sheet's "move" field (NOTE: this is a calculated field on the character sheet!) This usually comes up when I'm adding a bunch of bad guys to the map. Say I suddenly need to add five Sathar grenadiers to the map. Naturally, I would like to combine tasks 2 through 5 into an API script fired by step 1. In fact, I'm surprised step 2 isn't already part of Roll20 as a built-in feature. Obstacles: step 2) First off, I can't find a reference in the API for which character a token was added from. So my code can't identify which character to use. Even if it could, the API object reference says that the token's "references" field is read-only. step 3) I can do this. No problem. step 4) I can't do this at the same time (in one script). Idea: set the value, don't link it to begin with. I think that should work. No help needed. step 5) I can't figure out how to reference calculated attributes (or values) from the character sheet in the API.
1404307935
The Aaron
Roll20 Production Team
API Scripter
Hi Scotthammer, You don't need the API to solve this problem, you just need to link up the things you want on the monster tokens before adding them to the character sheet. This page on the wiki details the process. What you want is the Mooks portion: <a href="https://wiki.roll20.net/Linking_Tokens_to_Journals" rel="nofollow">https://wiki.roll20.net/Linking_Tokens_to_Journals</a>
Thank you. I've apparently been doing it wrong from the beginning.
1404346510
The Aaron
Roll20 Production Team
API Scripter
No worries. It was literally months before I figured this out. =D