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 .
×

Script calling Scripts

So I am making some basic scripts.  I want to know if I have multiple scripts saved can I call one script inside another script to process. For instance I have a selecting script that when a token or group of tokens are selected it returns their names.  I also have a healing script that heals selected tokens.  Now instead of writing a long script that basically both the selecting and then applying healing, I was wondering if there is a way to call the selecting script, get the names of tokens, then just heal them.   So basically a function that calls another external function.
All scripts in the API are active all the time... but why would you write a script to return token names to feed into a script to heal tokens when you can just heal the tokens directly without the names?
HoneyBadger I understand you can do that. Here's an example.  You have a Heal script and you have a Magic Missile script.  Both have the PC target a creature or creatures and modify their hit points. Both the Heal's and Magic Missile's script would probably have the same code to target and select Monster's/PC's.  Why duplicate the same code over and over to numerous scripts when you can have One Select Function that target's and selects Monsters/PCs.  Then call that Select Function for the Heal or Magic Missle and let them do their thing.  Basically it's to keep from having to duplicate the same code over and over and over.
You shouldn't use names though... use the unique token id instead. Which is built in to the selected function.
1379695522

Edited 1379695668
op = { ...     selected: [         {             _type: "graphic",             _id: "-Iva56adfadf"         }     ] } That function right there gives you the unique id of the selected token. TargetID = op.get("_id");
1379713778
Lithl
Pro
Sheet Author
API Scripter
HoneyBadger said: TargetID = op.get("_id"); Well... _.each(op.selected, function(tok) { TargetID = tok._id; });
Yeah, something like that, lol.