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

Macros interacting with token bars?

Hi guys, Is there a macro function that can reduce or increase a bar value of a token? For example if one of my bars was ammunition, after I do an attack then reduce bar by x. Thanks On another note, if I subscribe for the API stuff, can I use it in campaigns that I don't GM? Pete
Nope. The macro system is strictly read-only; it can't modify any values other than the Turn Tracker. If you upgrade to Mentor and make use of the API there's virtually nothing that you can't do with it. However you would need to be the GM of a campaign in order to make use of it in a game.
1404832857
The Aaron
Roll20 Production Team
API Scripter
The only value a macro can adjust currently is priority in the turn order (initiative). For anything more, you'd need the API. You have access to the API in any campaigns you create. Your GM would need to be a mentor subscriber to have access to the API in his game.
Thanks for the responses As a Mentor GM could I then interact with player made macros to give them this sort of feature? I would love to make a macro system that has if statements involved so it can be one button, tell if you hit something, do damage and sort out ammo.
1404834825
The Aaron
Roll20 Production Team
API Scripter
You can certainly activate api commands from a macro. API commands start with a ! and can be named whatever you like. The script simply has to respond to them. There are a few limitations, but mostly you can get any task accomplished with a combination of macros calling API commands. I'm not completely clear on what you are imagining with your last sentence, but I'm happy to try and talk out the implications of doing it with an API command and macros. =D Just to talk through a small example to give you the feel, it sounds like you'd want to do something like (in simplest form...) this, called via a macro: !attack @{target} bow @{target} prompts the caller to select a target token by clicking on it. The API command string will then look like '!attack -1234adsf13245afd bow', as the @{target} will be substituted for the token id before sending it to the API. In the API, you would have a script that listens to the command '!attack' var command = msg.content.split(' ')[0]; if('!attack' === command){ // do stuff } and expects the first argument to be the id of a token, and the second to be some action. The API can then find that token var token_id = msg.content.split(' ')[1]; var token_obj = findObj('graphic',token_id); and perform some action for 'bow': var action = msg.content.split(' ')[2]; switch(action) { case 'bow': // verify there is ammunition // check to hit vs token_obj's AC // find damage and apply it to the token_obj // deduct ammunition break; } Hopefully that gives you an idea of what you're looking at. Feel free to ask questions, we're a helpful bunch!
That's exactly what I was thinking, many thanks