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

Selected token attacks target token

Hi there! I'm new to roll20 and writing macros in general. I'm hoping to get some help on what I hope is a pretty quick-fix problem. I want to write a script to allow my players to announce a specific enemy they want to attack. This is the script that I've written thus far: /em @{selected|token_name} Attacks @{target|<target_name> |AC} The script works well through to the target selection step. The output, however, fails to read correctly. It will state "<the PC's name> Attacks TARGET" and not the target tokens given name. For reference, each token is named. Any input as to what I'm doing wrong here? Is it the script or how I may have set up the tokens?
1405642095
vÍnce
Pro
Sheet Author
/em @{selected|token_name} Attacks @{target| AC} This will show the name of the "targeted" token. /em @{selected|token_name} Attacks @{target|token_name } If you want to display the targets AC as well, try /em @{selected|token_name} Attacks @{target|token_name} with AC[[@{target|AC}]]
1405642927
The Aaron
Roll20 Production Team
API Scripter
Hi Bren, First off, you're talking about writing a macro , not a script . A macro is a collection of commands you could just type into the chat, but save as a single collection to activate with the press of a button. A script is written in JavaScript, and runs in the sandbox to interact with your campaign behind the scenes. It requires access to the Scripting API, a Mentor level feature. With that out of the way, lets try to fix your problem. =D Can you post your actual output from the command? When I run it I get something like this: Aaron (GM) Drenach Attacks 16 This is because /em gets replaced by my current As: setting of "Aaron (GM)", my selected character is "Drenach", and the targeted creature has an AC of 16. If you run this command: /em <--AS] Selected: [@{selected|token_name}] Targeted AC: [@{target| |AC}] It should make this more clear. Here's my output: Aaron (GM) <--AS] Selected: [Drenach] Targeted AC: [16] As the GM, you can use the /emas command to select someone to attack as like this: /emas @{selected|token_name} Attacks @{target| |AC} Drenach Attacks 16 But that option is not available to your players. Possible work arounds: You can do this sort of thing with the API, as it runs with the GM's level of access, and you can have it send /emas commands all you want. It is a bit more complicated, but there are actually quite a few scripts that make use of this (HoneyBadger's most excellent Power Cards Script being foremost among them.). You can have all your players change their names in the settings to whatever their character is (or change their speaking As: setting). Obviously of limited utility if you have multiple tokens to control, etc. You can proceed with the macro as you have it written and ignore the names of the players, or possibly have them change their names to be short and innocuous, like 'A', 'J', etc. Hope that helps!