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

[Script] Conditions

The Conditions script lets you define attribute-modifying conditions and apply them to characters. Define a condition to refer to later: !condition create Entangled --icon cobweb !condition addeffect Entangled Speed / 2 !condition addeffect Entangled Dexterity < 8 Apply that condition to selected (or specified) characters: !condition apply Entangled !condition apply Entangled --character Bob For simple one-off attribute mods, use an anonymous effect: !condition applyanon Str + 4 Combine with cron and CommandShell to automate management: !condition apply Haste -c Speedy !cron -r 10 "!condition remove Haste -c Speedy" (cron will remove the "Haste" condition from Speedy after 10 rounds).
So it modifies the relevant stats? Then reverts them after the rounds have passed?
The attributes are reverted (or recomputed, if more than one effect was active on the attribute) when you remove the condition. If you have cron and CommandShell installed, then you can set up a cron job to automatically remove a condition after some number of rounds. Without cron and CommandShell, you have to issue the remove command manually. The script keeps track of the base attribute (putting it into state before overwriting it in the character journal), and updates it whenever you manually change it in the journal (the number you enter becomes the new base, and the new effective value is recomputed based on that new base). Clearing all conditions on a character ("!condition clear") will revert all attributes to their respective base values.
Ah. I see. Thank you :) That is much clearer.
hmmm so I've installed CommandShell, cron, and Conditions on a clean campaign to test it out. I'm able to do most of the commands you've given as examples, but the last one - using cron to execute a script - is throwing a permissions error ("Shell: Error: You do not have permission to execute command !condition"). As I said, I know from testing that I do have permission to execute these commands, and I've even tried manually adding myself to the permissions list using CommandShell ("!shell-permissions add !condition glenn") to no avail (btw, would be helpful if there was an option to list current permissions in CommandShell). Perhaps the issue is that the execution command is being chatted from CronD? Tried to give them permission in CommandShell, but that threw an error, too ("(From Shell):Unable to find user matching CronD"). Feeling a bit stuck, any suggestions?
Oh crappity crap crap. I didn't think about permissions when I added support for running API commands in cron (just by coincidence, I tested it using a command with global permission). I'll look into a way to either run cron commands as a specific user (or at least as the user executing the command) or to add permissions for virtual users like "CronD". In the meantime, you can work around it by granting global permission for the command ("!shell-permissions add !condition" without specifying a user), although this is obviously not ideal as players will be able to use it too.
1436052094

Edited 1436057211
Ohhh ok. Well, now I'm getting a different error: "(From Cond):Error: Must specify at least one character" followed by the conditions help chat box. Again, the command I'm trying to run works outside of being called by !cron (as in, I am appending -c followed by the character's id). I've tried specifying the character a few different ways, keeping them selected, but nothing seems to work.
Hmm actually, even commands like !condition apply Effect -c -JqGaAjpHqNEAJDk4bff are not working for me. The only way I can apply a condition is if the token itself is selected. On that note, is there any targeting functionality in the character specification? That would really put this script over the top for me (once this cron/character specification thing gets ironed out).
Wow, two stupid mistakes in a row. I'm on a roll. I blame the fact that I was rushing for the holiday weekend. On lines 877 and 900 of the script currently in the repo as v0.1, change "character" to "characters". I've got one other thing I want to to for v0.2 before I check it in, but that should be pretty soon.
1436066228

Edited 1436066902
Awesome, thanks! These scripts are really fantastic, can't wait to see what else you're going to do with them! Edit: lol now I'm confused about the lines to change. Lines 877 is "break;" and line 900 is just "}"
1436067127

Edited 1436067163
Hmm, guess I must have already had some of the modifications in when I grabbed those line numbers. In any case, the fix is up on my fork , so you can grab it from there, and a pull request is in (which I suspect will get merged into trunk on Monday).
There it is! Everything seems to be working swimmingly now -- and just in time for their boss battle this Sunday :>
Just picked up a little bug -- "!condition clear" removes the effects, but not the status icons. I was also wondering what the point of the description option is. None of the commands seem to print it (the logical place would seem to be list).
Good catch. I've fixed that for v0.3. The description shows up in the detailed condition listing ("!condition list Some_Condition"). I'm on the fence about putting it into the list of all conditions. On the one hand, it could be nice information to have. On the other hand, it could be information overload to list all defined conditions and all their full descriptions.
Cool. Well I've tested the desc command both ways and right now when I do the detailed listing, I get the icon, followed by "[object Object]" on the line below it, and then all the effects I've added to the condition. No description. I agree that the detailed description is probably better called up on a case-by-case basis with the detailed listing.
1436200746

Edited 1436201018
DK Heinrich
Marketplace Creator
Sheet Author
when active at the same time that powercards is active both give an error of 'unexpected token', removing condition lets powercards go back to working correctly. EDIT: more details. When both are active I get the above message, when conditions is disabled it does nothing, and powercards says that it is reloading sandbox but never does. If I delete conditions then powercards goes back to working correctly.
1436211851
The Aaron
Pro
API Scripter
Try putting a carriage return and ; at the end of each script.
1436212335
DK Heinrich
Marketplace Creator
Sheet Author
added it to this script and seems to be rocking (well at least they all like each other again), thank you sir!
1436213376
The Aaron
Pro
API Scripter
No problem. I think it was discussed in another thread, but I believe Power Cards ends in a comment but has no carriage return, so when the scripts get simplistically concatenated, that comment ends up commenting out the first line of the next script and madness ensues. =D
If I'm reading this correctly, this is capable of altering strength, dex, con, etc, but it can't do something like add a damage bonus to attack rolls while someone is raging. Is that a correct understanding of the script as it stands?
Man, I was really off my game for this one. I was missing a ".desc", and so appending the condition object, rather than its description, to the output. That's where the "[object Object]" was coming from: it's what javascript gives you when you try to coerce an object to a string. Fixed in v0.4. The script can alter any character attribute (although I doubt it plays nicely with calculated attributes -- I'm really not sure what happens if you try to manually set a value for a calculated attribute, but it probably isn't good). Whether that translates to a damage bonus or some such is up to you and your macros. If you want to add a rage bonus to your damage, create a "Rage_Bonus" attribute with a value of 0, add "+@{Rage_Bonus}" to your damage macro, and then run something like "!condition applyanon Rage_Bonus +2" (or fold the Rage_Bonus modifier into a named condition).
Thanks for responding. Your answer got me to the solution I wanted. I'll post it below basically in case anyone else is looking to do this. I'm using the 5e Shaped Sheet. In the weapons section, there's a table for bonuses and penalties to your attacks and damages. A raging barbarian gets a +2 to melee attack rolls so the attribute you're looking to affect is global_melee_damage_bonus. So all it took to get it to work was: !condition create Raging !condition addeffect Raging global_melee_damage_bonus + 2 Thanks again!
Sorry I'm back with a quick followup. I installed cron and commandShell to try to automate it a bit and copy and pasted your code precisely into the macro. After running through initiative the appropriate number of times, the I get this feedback: Shell: Error: You do not have permission to execute command !condition CronD: !condition remove Raging -c Josiah I've never used cron or commandShell so I'm a bit lost. I am the DM in my game so I'm baffled that I wouldn't have permission.
That isn't coming from Roll20, it's coming from CommandShell. The root of the issue is that cron executes commands as "CronD", not as the player who set up the cron job. There's a message a ways up about this; the workaround for now is to do "!shell-permissions add !condition", which will add permission for anyone to execute the "!condition" command. I haven't had a chance to come up with a better solution to this yet.
Thanks, I got the error message to disappear. I'm really enjoying the script. I need to work with it a bit more I think but my issue is with cron, not your script. I did want to ask, is there any way to add a dice roll to an attribute? For example, cleric casts bless, which adds a d4 to all attack rolls. I'd like to add a d4 to the character sheet element.
So the problem with user permissions comes down to the fact that, when you use sendChat with a callback, that callback's argument has playerid="API", even if you set speakingAs to something like "player|-123abc". I modified CommandShell's sendChat wrapper to set playerid appropriately if speakingAs is a player ID, so it's now possible to run "!cron -f player|-123abc -a 1 !foo" and have it execute "!foo" as player -123abc (using that player's permissions), starting with CommandShell v1.3. To make that a bit easier, I modified cron to default to the user scheduling the job, so "!cron -a 1 !foo" will execute "!foo" as you (using your permissions), starting with cron v0.7. The pull request for both of those modifications is in, and will probably be merged in soon. In the meantime, you can get them from my fork .
I would really like to see these features in future iterations of this script: 1. Support for inline rolls, calculating a value each time the condition is applied (and removing the same value when it is removed). For example, !condition addeffect Condition_name AC-temp +[[1d6]] 2. The ability to reference attributes on the token the condition is applied to (pulled from their linked character sheet), checking the attribute each time the condition is applied and using it to calculate a value for an effect. !condition addeffect Condition_name Bonus_damage +[[@{CHA-mod}]] Any plans along these lines? Or are they not feasible?
1440084171
DK Heinrich
Marketplace Creator
Sheet Author
when I add a description (-d) to a condition - how/where does that description display?
1440085195
DK Heinrich
Marketplace Creator
Sheet Author
and using this with drop down menu seems to be working well.  !condition apply ?{Pick One|ASLEEP|BLINDED|FATIGUED} -c @{target|token_ID}
I love this script, and everything about it. The only thing I am pulling my hair out about, is that if I am using TheAaron's TurnMarker script, and use !eot to end turn (so players can end their turn, instead of relying on the GM), rounds are not counted for the cron command to be executed after the rounds have concluded. I can spam !eot 100 times, and the cron will not execute. If I use the button on the Turn Tracker to advance the turns, the cron command will execute at the requisite time...
1440365277
The Aaron
Pro
API Scripter
I know how to fix that. Just need the time to do it. :)
Well, that makes me feel better. I was seriously wanting to drive an ice pick through my eyes. For some reason, I can see it as being an easy "fix," but this is one time I just feel like my head is empty...
1440370895
The Aaron
Pro
API Scripter
If you look at the interaction between GroupInitiative and Bump, you'll know how I'm thinking of fixing it.  You could also add a !eot command to this script that just makes it do what it does on a turn change.
If I added an !eot to this, would it be like dividing by zero, or are you referring to everything but the command itself? I thought about adding the "guts" of the !eot to this, but I say in my chair for the better part of an hour staring at my computer trying to figure out where to begin today... my brain has been fried from 17-credits worth of Philosophy, English and Business Admin classes this summer, only to have the fall semester begin with another 18-credits next week.
1440374002
The Aaron
Pro
API Scripter
:) Since an API command is passed to every script, you would still be using the !eot in TurnMarker, and simply catching it being called in the other script to do the things you'd do in the on('change:campaign:turnorder',...) callback. 
Hmmmm...
I think I may be able to disregard my own stupidity in this... if I append the macro which simply says !eot with !cron -f USER -A 1, it appears to do what I need it to do...
1440484037

Edited 1440484568
I'm interested in this but hesiitant as I've found when it comes to a lot of apis, the usefulness of them is inversely proportional to the complexity of the syntax. Is there a way to simplify the syntax through macros or something? Typing out -condition apply slowed - - character Balok. Is slower than just selecting the character and placing the symbol on it. Though I do see how much easier this makes, making sure everyone uses the right symbol. 
Oh and any chance a save scripti could be added to this? Something like !condition save slowed - - Bob 1d20-5 10 would tell it to roll a 1d20-5 and if it rolls 10 or higher remove the slowed condition.
To your first: you can create a macro, !condition apply slowed --c @{target|token_id}, and anyone can use it if you have set !condition as usable by all with !shell-permissions add !condition.  
I'll ask my players then if they want to try it.
1440533160

Edited 1440533178
You could make the macro yourself, then share it with them. I do that with several of my macros, that way they don't have to make changes if there are any to be made in the future. All they ever have to do, is check the box to show the macro, then press the button as needed.
Hello i have a little problem with the script (it work fine) but when i put a 10% Strong penality to my character who had 28 in strong and the result in the character journal is a number with coma but number with coma can't be roll it always say 1 in the result. There is a way to put the uper or downer number instead the coma number ?