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

is it possible for the api to have your cursor reselect your token after performing a target command

is it possible for the api to have your cursor reselect your token after performing a target command?
Nope.
*sadface* What about a work around then? To select the name of a token specified in a macro after the targeting has been done? (Generally I don't like starting to work with the API if its going to be fruitless without knowing :()
1405863922

Edited 1405868807
The Aaron
Roll20 Production Team
API Scripter
Depending on your use case, you could do something like: !action set-player !action perform-action ${targert|...} In the first !action, record the selected array. In the second !action, use the recorded selection array along with the target. This works great if you're running the commands from a macro.
1405868798
The Aaron
Roll20 Production Team
API Scripter
Here's a working example: var SelectAndTarget = SelectAndTarget || (function() { 'use strict'; var HandleInput = function(msg) { var args; if (msg.type !== "api") { return; } args = msg.content.split(" "); switch(args[0]) { case '!action': switch(args[1]) { case 'set-player': log('setting player...'); log('msg: playerid: '+msg.playerid); state.SelectAndTarget[msg.playerid]=msg.selected; break; case 'perform-action': _.each(state.SelectAndTarget[msg.playerid], function(s){ log('Selected: '+ s._id); }); if(args[2]) { log('Target Attribute: '+ args[2]); } break; } break; } }, Initialize = function() { if(! _.has(state, 'SelectAndTarget') ) { state.SelectAndTarget={}; } }, RegisterEventHandlers = function() { on('chat:message', HandleInput); }; return { Initialize: Initialize, RegisterEventHandlers: RegisterEventHandlers }; }()); on("ready",function(){ 'use strict'; SelectAndTarget.Initialize(); SelectAndTarget.RegisterEventHandlers(); }); If you make a macro with these contents: !action set-player !action perform-action @{target|ac} It will log the selected array and the ac of the target on the second command. Hope that helps!
I am hashing out a "workaround" where the API function call passes the ID of the selected token to the API this way: !attack @{selected|token_id} @{target|token_id} I am pretty sure that the reason this works is because the @{selected} expression is resolved before the @{target} expression is called.
1406026701
The Aaron
Roll20 Production Team
API Scripter
Oh? Does that work? Good idea!
If you could manage to make that work, I would be forever grateful. It saves the hassle for buttons between character sheets which calls for targets etc.
1406032108
The Aaron
Roll20 Production Team
API Scripter
I'll be darned. That does work. =D