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

[Scripts] Star Wars Edge of the Empire Scripts for range and destiny tokens

New to roll20 and APIs/Scripting but one of my players and I managed to work up some scripts for Edge of the Empire, Age of Rebellion and Force and Destiny. The first is to display the medium and short range bands as auras for weapons and movement. <a href="https://gist.github.com/5b14da33afd54bcae0e8.git" rel="nofollow">https://gist.github.com/5b14da33afd54bcae0e8.git</a> We also adjusted Peter Ws Range Finder script <a href="https://app.roll20.net/forum/post/537763/script-ra" rel="nofollow">https://app.roll20.net/forum/post/537763/script-ra</a>... to print the relevant range band instead. All credit to him, we just added an if statement. <a href="https://gist.github.com/cea5aa7d8ade1f2598ce.git" rel="nofollow">https://gist.github.com/cea5aa7d8ade1f2598ce.git</a> We also manged to make a basic destiny token tracker so we could just use roll20 without having to use the Edge of the Empire hangout app. <a href="https://gist.github.com/6b25dbf9d52843b5bb83.git" rel="nofollow">https://gist.github.com/6b25dbf9d52843b5bb83.git</a> They are all super basic and probably very inefficient we aren't particularly familiar with coding, but they work. Any tips or changes are welcome.
1409760826
The Aaron
Roll20 Production Team
API Scripter
Congrats on your first script release! I do have a few suggestions for you, since you're asking. You can simplify your set operation by passing an object instead of calling .set() multiple times: token.set("aura1_radius", "10"); token.set("aura1_square", false); token.set("aura1_color","#FF0000"); token.set("playersedit_aura1", false); token.set("aura2_radius", "50"); token.set("aura2_square", false); token.set("aura2_color","#FFFF00"); token.set("playersedit_aura2", false); token.set("showplayers_aura1", true); token.set("showplayers_aura2", true) becomes: token.set({ aura1_radius: 10, aura1_square: false, aura1_color: '#ff0000', playersedit_aura1: false, aura2_radius: 50, aura2_square: false, aura3_color: '#ffff00', playersedit_aura2: false, showplayers_aura1: true, showplayers_aura2: true }); You can also build those up separately and combine them as needed: var shortRangeAura={ aura1_radius: 10, aura1_square: false, aura1_color: '#ff0000', playersedit_aura1: false, showplayers_aura1: true }, clearShortRangeAura={ aura1_radius: '', showplayers_aura1: false }, mediumRangeAura={ aura2_radius: 50, aura2_square: false, aura3_color: '#ffff00', playersedit_aura2: false, showplayers_aura2: true }, clearMediumRangeAura={ aura2_radius: '', showplayers_aura2: false }; // if short and medium both on.. token.set(_.extend({},shortRangeAura, mediumRangeAura); // if just short range token.set(_.extend({},shortRangeAura, clearMediumRangeAura); // etc That would allow you to parse all your commands in a single on('chat:message',...) function, which would shorten the code a bit and make toggling easier. Cheers!
That's all really helpful, thanks heaps for taking the time to give us some tips. Couldn't get these sort of pro tips from reading the Roll20 API Wiki :p
1409788280
The Aaron
Roll20 Production Team
API Scripter
I take it you're the "one of my players?" =D
1409791635

Edited 1409799580
The Aaron
Roll20 Production Team
API Scripter
So, if I had my druthers, I'd reorganize your range band scripts like this: GIST: <a href="https://gist.github.com/shdwjk/437a80205ab5b7947466" rel="nofollow">https://gist.github.com/shdwjk/437a80205ab5b7947466</a>
That's fantastic, save's us having 3 different scripts. Though it seems to have an issue with the other scripts or our other scripts have issues, when the range checker or destiny tracker prints to the chat, the help stuff for the rangebands prints too.
1409794373
The Aaron
Roll20 Production Team
API Scripter
Do you still have the other 3 bands scripts enabled? It will print the help when there are no tokens selected and no valid token ids specified.
I disabled the old ones. It does pop up when I don't select a token, but also when I use the destiny script. It's weird.
It also throws up "Error: Argument [ status ] is not a valid token id."
1409799397
The Aaron
Roll20 Production Team
API Scripter
OH!! ok I know what I did there.. =D
1409799635
The Aaron
Roll20 Production Team
API Scripter
OK. I updated the GIST above. =D I had forgotten to make sure I was getting the right commands... =D Ooops. =D
ah cheers. Thanks again. XD
1409802233
The Aaron
Roll20 Production Team
API Scripter
No worries. Feel free to ask my anything, I try to be as helpful as possible. =D Plus I'm addicted to scripting...
he is.... he really really is... and we love it.
1410706928
The Aaron
Roll20 Production Team
API Scripter
;)
1411603291

Edited 1411605460
Ok folks just how do us novices/non programming types actually use this in a game? I have copied and pasted the script into my campaigns API, but what now? what are the chat commands to use it? THanks ok, never mind, a little trial and error and i seem to have stumbled on how to use this API... I must admit it looks great! Thanks for making this.