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 .
×

Unsure why this macro doesn't work? (includes API scripting command)

I'm trying to create a drop-down macro that lets me toggle between different light states for tokens. This is my macro: ?{Type of Light |    Torch or Light, !torch 40 20 yes |    Darkvision, !torch 30 0 no |    Enhanced Darkvision, !torch 500 500 no |    No Light, !snuff } But when I run it it just prints the command to the chat log, instead of actually invoking the command. I don't think there are any special characters in there that need to be escaped but just in case I tried escaping the exclamation point, but this did not change the behaviour. What am I doing wrong?
1580757809
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
You are likely running into problems with HTML substitutions . You would be much better served by a chat menu: &{template:default} {{name=Type of Light}} {{=[Torch or Light](!torch 40 20 yes) [Darkvision](!torch 30 0 no) [Enhanced Darkvision](!torch 500 500 no) [No Light](!snuff)}} You can put a  /w gm  in front of line 1 if you don't want the players to see the menu.
1580761712
GiGs
Pro
Sheet Author
API Scripter
It might also be something simpler - I havent used the torch script, but some scripts require the ! to be the very first letter on a line. With  Darkvision, !torch 30 0 no | there's a space after the first comma, so a space is the first character on the line.  Changing it to  Darkvision,!torch 30 0 no | is worth a try.
1580765476
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
That's good to know. I never use dropdowns for API commands,
1580784288
The Aaron
Roll20 Production Team
API Scripter
All scripts require ! To be the first character in the message, unless they're very poorly written. The message will only have the api type if the first character is a "!".  This will probably work: ?{Type of Light |    Torch or Light,!torch 40 20 yes |    Darkvision,!torch 30 0 no |    Enhanced Darkvision,!torch 500 500 no |    No Light,!snuff }
It was indeed the space between the comma and the exclamation point. Thank you everyone for your help.