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

Entering Macros/Attributes/Inline Rolls as plain text for API?

Not sure how to properly describe this, but I'm trying to write up a script that uses the the api chat feature and takes in a macro/attribute/inline roll as an argument. I intend to use it such that the api will take what I input and create an Ability object out of it to put into the character tokens I've selected. Example: !test @{selected|character_name} The issue, however, is that I don't know how (if it's possible) to have the text input into the API as is,  because as it currently goes, it parses the string before it sends it off into the chat. So if given this code: on("ready", function() { on("chat:message", function(msg) { log(msg.content); }); }); The log shows this: "!test Some guy" Rather than what I want it to show, which is this: !test @{selected|character_name} Is there some kind of escape character I can put in or something?
1539490672

Edited 1539490720
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
You'll need to do HTML replacements of anything that has a command effect. This is obviously a huge pain. I'd recommend instead entering the info in as a character ability, bio/info, or gm note, or as a global macro and then copying the ability text to the characters of your choice. Also, a note. This may just be a misunderstanding of roll20 terms, but you can't add abilities directly to tokens. You can add them to characters and then set them to be token actions so they'll show up as a token action.
Scott C. said: You'll need to do HTML replacements of anything that has a command effect. This is obviously a huge pain. I'd recommend instead entering the info in as a character ability, bio/info, or gm note, or as a global macro and then copying the ability text to the characters of your choice. Also, a note. This may just be a misunderstanding of roll20 terms, but you can't add abilities directly to tokens. You can add them to characters and then set them to be token actions so they'll show up as a token action. Ah understood. I already have a separate google sheet to create my commands for me, so it shouldn't be too big of a hassle to incorporate a way to replace the characters when necessary. Just to be clear, though, I have to replace the characters like so? { -> { } -> } etc.
1539494178

Edited 1539494225
GiGs
Pro
Sheet Author
API Scripter
If you're constructing the abilities in your script, you dont need to pass attributes as the original reference. Instead of passing, say, @{selected|character_name} you can pass character_name , and convert it to the string  @{selected|character_name} within your script.
1539494351
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Yep, or create your own alternative syntax.
Oh, good idea. Thank you!