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

Looking for workaround: special characters in API buttons


Edited 1649384529
I've been working on a fairly hefty script for use in my games that makes a lot of use of the API buttons in chat.  e.g.: [BUTTON](!callintoscript with params) Usually this has allowed me a great deal of flexibility in how I can use it to pass more commands to my script and form fairly functional menus for my project. The catch is, that when attempting to pass a chat command such as @{target|token_id} to the button like this: sendChat("DEBUG","[BUTTON](!lncr_core_TargetSetTokenMarker @{target|token_id} burn)");  at some point in the process, the symbols for the target commands are getting stripped out of the call And recalling the previous command using in the chat window produces this: !lncr_core_TargetSetTokenMarker target|token_id burn I would like the ability to trigger the Target functionality using a button instead of a macro, since I could use it to dynamically pass params but it looks like I'm going to need some kind of workaround. Does anyone have any ideas? For the record: Using a macro works fine - "!lncr_core_TargetSetTokenMarker @{target|token_id} burn" produces the desired effect when used both in the chat window and a macro.

Edited 1649389666
Sheet Author
API Scripter
It's not actually getting stripped out, it's just getting parsed. Paste this straight into chat: [BUTTON](!lncr_core_TargetSetTokenMarker @{target|token_id} burn) See what happens? As soon as you hit enter, the chat parser tries to resolve the target call by prompting you. If you do click something, you're going to end up with a button that looks like this: [BUTTON](!lncr_core_TargetSetTokenMarker -sdgh289gh2egh29 burn) The token_id is already baked into the button's <href> string. Since your script is doing this from the API with sendChat(), and the API doesn't have a browser window, or a mouse, or a brain, the target call can't be resolved. Since what you want is for the target prompt to come up when a user clicks the button (and not when we create the button), you just need one round of escaping so the chat parser ignores the target call when you create the chat button, but you end up with the correct syntax baked into the button: [BUTTON](!lncr_core_TargetSetTokenMarker @{target|token_id} burn) You can generally get away with just escaping the @ with @ but I've had a few issues with stray opening braces before, so usually escape both of them. Hopefully this makes sense....

Edited 1649436096
Thanks for the quick response! I'll give it a shot and report my findings. That worked! Thanks for the assist!
Sheet Author
API Scripter
No worries.