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

Modifying an existing script, need some help on how to approach it

Hey everyone, I don't have a lot of experience with JS, but have dabbled in some python. I'm trying to modify this script for Fx on a token so that instead of it being random, it's actually selected by the DM. I've got a couple of ideas how to accomplish it, but lack the know how on how to actually. Idea 1( the one i like the most): Put all of the required information in the dmnotes, and parse that for the requisite properties. I saw something like this done by Ken L in a pathfinder script for making monster tokens. I like this because it should give the most control to the DM. I like it because it'd be persistent (the script would just need to be started, no need to re-do information. Idea 2 (don't think this is feasible): Have a dialog box pop up where the DM would enter in the needed information. It's pretty, but could be tedious, and would need to be redone every time the GM wanted to use those effects. Idea 3 (definitely do-able, even by a scrub like me): Make an API script for each of the effects, and change the current random array to one thing only, and change the trigger word for each one to something like !burstFire, !burstPoison and so on. Certainly do-able, but given the number of potential scripts that could be, probably not a good idea.
1529427592

Edited 1529427646
The Aaron
Pro
API Scripter
If you're just looking for the end result, there's a PageFX script that already pull continuous effects from the GMNotes of a token. If you're looking for experience modifying scripts, then carry on!  You can definitely do Idea 1.  That script is pretty thoroughly annotated, but if you have questions, I'm happy to help answer them. =D  Probably you'd add a new function around line 27, something like getEffectFromGMNotes(), which would load the GMNotes of the token and pull the effect name out of it.  There may be some complications if the GMNotes on Tokens require asynchronous access (pretty sure they don't), but you can burn that bridge when you come to it. =D
Thanks for the ideas. I think where' i'm getting caught up is it seems like to get information from the selected token(s), it takes a list of statements three levels deep. But I'll take a look at the area around there, and see what I can do. and if I fail, now i know there's one to do it :D
1529428650
The Aaron
Pro
API Scripter
Yeah, that's a good point.  You would need to pass the token to applyEffect() as a 4th parameter, or pass the effect in, which might make more sense really.  Of course, then there's no point to applyEffect, so you might as well be calling spawnFx() directly instead. Changing:                                     // If we found it, we'll do some things (otherwise, it was deleted and we'll stop)                                     if(t){                                         // With the graphic in hand, we can now apply an effect to it's current position.                                         applyEffect(t.get('left'),t.get('top'),p); to something like:                                     // If we found it, we'll do some things (otherwise, it was deleted and we'll stop)                                     if(t){                                         // With the graphic in hand, we can now apply an effect to it's current position.                                         spawnFx(                                         t.get('left'),                                         t.get('top'),                                         getEffectFromGMNotes() || randomEffect(), p                                         ); then implementing getEffectFromGMNotes() should do it. =D