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

Using TokenMod script inside a nested query macro with FX

Hey all! Hoping for some help. I'm trying to run a simple TokenMod command inside of a macro, inside a nested query, and I just can't figure out what I'm doing wrong. Seperately, the two elements work fine. Here's the TokenMod script. I'm basically telling the token to reduce Bar3 (our monk's ki point bar) by 1. !token-mod --set bar3_value#-1 --ids@{selected|token_id} And here's the original macro (with nested query): /em ?{Are you using Fangs of the Fire Snake?| Yes,?{Would you like to spend a ki point to deal an additional 1d10 fire damage?&#124 Yes&#44sears @{target|Enemy|token_name} for [[1d6+1d10+@{dexterity_mod}]] fire damage! /fx burst-fire @{target|Enemy|token_id}| No&#44sears @{target|Enemy|token_name} for [[1d6+@{dexterity_mod}]] fire damage! /fx burst-fire @{target|Enemy|token_id}&#125| No,strikes @{target|Enemy|token_name} for [[1d6+@{dexterity_mod}]] blundgeoning damage! /fx glow-blood @{target|Enemy|token_id}} But when I try to combine them... /em ?{Are you using Fangs of the Fire Snake?| Yes,?{Would you like to spend a ki point to deal an additional 1d10 fire damage?&#124 Yes&#44sears @{target|Enemy|token_name} for [[1d6+1d10+@{dexterity_mod}]] fire damage! /fx burst-fire @{target|Enemy|token_id} !token-mod --set bar3_value#-1 --ids@{selected|token_id}| No&#44sears @{target|Enemy|token_name} for [[1d6+@{dexterity_mod}]] fire damage! /fx burst-fire @{target|Enemy|token_id}&#125| No,strikes @{target|Enemy|token_name} for [[1d6+@{dexterity_mod}]] blundgeoning damage! /fx glow-blood @{target|Enemy|token_id}} ...all the parts of the original macro execute fine, but the tokenmod script doesn't reduce the value of bar3. Anyone see where I'm going wrong with this? Is it something to do with the HTML replacements? Thanks in advance!
1572446831

Edited 1572446936
Ziechael
Forum Champion
Sheet Author
API Scripter
In a meeting so can't test straight away but are you missing a space after the ids call in the token-mod line? There is also a possibility that the use of @{target is de-selecting the token so @{selected isn't working? Try hard coding the token id and see if that works.
>.<  >.<  All down to a space... thanks again Ziechael, that was totally it. What's confusing to me is that the tokenmod line works fine by itself  without  the space after the ids call, but I guess that's important when going into a larger macro? Also, where do you see/how do you hardcode a token id? I have a follow-up question (for when you're out of your meeting of course), mostly about a good substitute for "selected." I'm creating these macros for my partner's player character, since she is relatively new to D&D and will be brand new to Roll20. Trying to keep it as simple as possible so there are less things to remember or keep track of. The problem with using the @{selected|token_name} is that it's obviously VERY easy to mess something up (and spam chat with 100 error messages) if you try clicking on a character macro without selecting your character first. I could just make the macro a token-only macro, but I prefer the organization/color-coding/renaming functions that the token bar offers. Long-winded way to ask; is there a good way to target "self" or "character" instead of "selected" for macros? Something like: The health potion heals @{character_name} for 4 hp! or anything like that.
1572454311

Edited 1572454515
Ziechael
Forum Champion
Sheet Author
API Scripter
Happy to help... I find the more complex your stuff gets the more mindful of spacing you need to be, even inline rolls can suffer without spacing [[1d6]] v [[ 1d6 ]] for example. As a rule I always 'pad' my rolls with a space at either end. With regards to the ids, you can get a token, or even a character id by running @{selected|token_id} on a selected token or @{target|token_id} if you want to select a token after the macro. It will output the relevant ID to the chat which you can use in place of selected/target calls for things like tokenMod. To avoid the potential for @{selected... catastrophes you can either exclusively use @{target... which would then prompt the user to select their own token after running the macro, the issue here is if the macro has a target to select already in which case you'd use query labels (@{target|Select Yourself|token_id} etc and @{target|Select Thine Enemy|armour_class} etc). By keeping the labels the same you should only get the two prompts, one to select the users token and one to select the enemies... of course that can be scaled by having '@{target|Select Thine Enemy 1...', '@{target|Select Thine Enemy 2...' etc etc if you wanted the option for multiple targets. Another option, if these are hardcoded macros for a specific user is to use the name of the character as the attribute call: @{Bob the Slayer|armour_class} for example. You lose the flexibility for these macros to be used by anyone else but remove the need to have the token selected or chosen as a 'target' to pull info from. To quote your example (although it would be needlessly restrictive for that use case): The health potion heals @{ Bob the Slayer| character_name} for 4 hp! ^^ That one is firmly in the realm of @{selected... or likely better yet @{target...
1572454735
Ziechael
Forum Champion
Sheet Author
API Scripter
From just checking through some threads related to this I'm reminded that you'll need to make sure that  Player can --IDS  is turned on in the  !token-mod --help  if someone other than the DM is going to be running the macros with the id related tokenMod calls in them.
Thanks Ziechael! I'll remember that about the spacing. ;)   I do like the workaround (or, I guess "safety net") of using "target|Your Character" instead of selected. Targeting seems to come up early in the order of Roll20 operations, whereas macros with "selected" lines will still try to execute other commands and might end up flooding the chat with errors. Just tried it out and it works great. Using the character's name also sounds interesting, but a) it doesn't seem to work for things that affect tokens specifically, like changing the value of a bar with TokenMod, and b) like you said, eventually I'd like to start make these macros available to other players. And thanks for the reminder about Player can --IDS , I've read about it on these forums as well and just turned it on!
1572505410
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Here's the Order of Operations , in case you are interested.