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

[TokenMod] [API/Macro] Pass value from chat macro invocation to script?

My apologies if this is documented somewhere, I've looked at a lot of things trying to find it before asking. I'm using the TokenMod script to set the value of the first bar on a token that is selected. This works from chat: !token-mod --set @{selected|token_id} bar1|30 This also works from chat: !token-mod --set @{selected|token_id} bar1|-5 I would like to invoke this more easily, from the chat, so I made this macro, called #shp: !token-mod --set bar1_value| What I want is for the macro to pass whatever comes after #shp to the invocation of token-mod, but I can't get it to work. Adding a + at the end, which works with roll macros, does not appear to work here. This definition of the macro works fine, but will always set the value to 20 when I invoke #shp (not that useful): !token-mod --set bar1_value|20 This definition of the macro also works fine, but requires me to enter the desired value via an input box: !token-mod --set bar1_value|?{HP} Is there a way to turn `#shp +5` into `!token-mod --set bar1_value|+5` via macro definition? Or would I have to write a script to effectively do the same thing? Thanks, Tadhg
1458961167
The Aaron
Pro
API Scripter
Good question. I've not tried working with macros like that. With the space after #shp, that would become: !token-mod --set bar1_value| +20 which would be parsed as two arguments to --set, neither with a parameter.  I could likely write you a quick script that does what you want. Can you describe in more detail the things you want to do?
Thanks Aaron! But if a script is required, I'll try to write it myself—I need practice with the API. I'll report back if I get somewhere (or if I get stuck and need to ask for help). The main reason I want this is because I tend to prefer operating from the keyboard as much as possible, so I'd like to be able to set various character values with a minimum of keystrokes. Ideally, it would be great if macros had a formal operator for capturing parameters, something like `={}` (similar to `?{}`). A way to indicate how many parameters you want to capture and/or what to do with extras would be excellent as well. Even more ideally, it would be fantastic if there were a hybrid along the lines of `=?{HP}` that would take parameters specified after the macro in chat, so that e.g. `#shp +5` would pass `+5` to whatever the macro is calling, but `#shp` with no arguments (or from a token action call) would pop up a dialog box in the same way that `?{HP}` currently does. I don't know if it would be possible to do this via scripting or if this is a feature request. I also found <a href="https://app.roll20.net/forum/post/741734/script-m" rel="nofollow">https://app.roll20.net/forum/post/741734/script-m</a>... which might provide another approach for what I'm trying to do.