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

Saving state/config

1448824408

Edited 1448824517
Hi All! I'm hoping this is a simple question.  I've got a pseudo-combat automation API running.  For the most part it is running really well (yes, that is said with some surprise ;-)).  However, in order to determine advantage/disadvantage I currently prompt (via query) my players on every attack they make.  Since most combat is 80% or more advantage/disadvantage free this gets a bit tedious in my opinion. What I was wondering is if there is a way to have a macro button sitting on their quick bar that they would click, get a chat message with a couple of API buttons on it, click one that would config that attack for either advantage or disadvantage, and then reset itself back to default of standard when done?  This way, normal combat can flow along without a lot of unnecessary prompting until it is necessary. I was taking a look at a couple of Aaron's scripts, especially tokenMod, and see that you can set the "playersCanUse_ids" on the fly by clicking the API button to toggle it.  Now that gets stored across the whole session (until next sandbox spin up), correct?  Although, for this I only want it to be toggled until the current player is completed with their turn.  Possible?  If so, a simple example would be appreciated and I can take it from there. Thanks!
You know, I ask a question and then an idea pops into my head that answers it for me. ;-)  I can do the toggling and then just have the attack script turn it off after it is done.  So it can be configured for advantage/disadvantage ahead of the attack and then the script just will toggle it back to standard before exiting.  Sound like a plan?
1448830725
The Aaron
Pro
API Scripter
Totally possible.  You'll want to setup your state object for your script to have a section like (I use a more complicated method of managing my state objects, but this is good for a simple illustration): state.CraigLAutomation = state.CraigLAutomation || {}; state.CraigLAutomation.playerAdvantageDisadvantage = state.CraigLAutomation.playerAdvantageDisadvantage || {}; // ... time passes ... // set advantage: state.CraigLAutomation.playerAdvantageDisadvantage[msg.playerid]='advantage'; // or set disadvantage: state.CraigLAutomation.playerAdvantageDisadvantage[msg.playerid]='disadvantage'; // ... time passes ... // use advantage/disadvantage if( state.CraigLAutomation.playerAdvantageDisadvantage[msg.playerid] ){ if('disadvantage' === state.CraigLAutomation.playerAdvantageDisadvantage[msg.playerid]) { // handle disadvantage stuff } else if ('advantage' === state.CraigLAutomation.playerAdvantageDisadvantage[msg.playerid]) { // handle advantage stuff } // cleanup setting for player delete state.CraigLAutomation.playerAdvantageDisadvantage[msg.playerid]; } else { // handle flat roll } Hope that helps!
Thanks, Aaron!  I took some inspiration from your TokenMod script and came up with something close to what you have above.  This will work perfectly.