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

API to move/ping specific players, not all of them?

The title says it all. I've looked around and come up short so I'm hoping you guys can help me. Is there an API or script that lets you move a specific player's view to a token without moving everyone else's?
1571446835
GiGs
Pro
Sheet Author
API Scripter
No, I'm pretty sure there's no way to do that.
1571496996
The Aaron
Roll20 Production Team
API Scripter
Actually, you can do that with the API!  It's a recent change and I've not gotten around to writing something for it. What would the interface look like to you?  Do you want to ping-pull by controlled by on a token, of do you need to specify a player with a drop down? Or do you need to do multiple players via the command line? 
1571500593
The Aaron
Roll20 Production Team
API Scripter
Here is a very simplistic script that will ping pull the controlling players to the selected tokens.  Will pull anyone who can control a token or character a token represents.  It will ping for every selected token, so if you're on several, your screen might jump around.  Only the controlling players see the ping happen.  If all is in the control list, everyone is pinged: !pull-players Code: on('ready',()=>{ const getControllingPlayers = (token) => { let players = token.get('controlledby') .split(/,/) .filter(s=>s.length); if('' !== token.get('represents') ) { players = [...new Set([...players, ... (getObj('character',token.get('represents')) || {get: function(){return '';} } ) .get('controlledby').split(/,/) .filter(s=>s.length) ])]; } return players; }; const sendPingControllingPlayers = (token) => { let players = getControllingPlayers(token); let left = token.get('left'); let top = token.get('top'); let pageid = token.get('pageid'); if(players.includes('all')){ sendPing(left,top,pageid,null,true); } else if(players.length){ sendPing(left,top,pageid,null,true,players); } }; on('chat:message', (msg)=>{ if('api'===msg.type && /^!pull-players\b/.test(msg.content) && playerIsGM(msg.playerid)){ (msg.selected||[]) .map(o=>getObj('graphic',o._id)) .filter(g=>undefined !== g) .forEach( t=> sendPingControllingPlayers(t)) ; } }); });
1571504704
GiGs
Pro
Sheet Author
API Scripter
Very neat! You can only do it with the API?
1571519473
The Aaron
Roll20 Production Team
API Scripter
Yes
1571519704
GiGs
Pro
Sheet Author
API Scripter
Thanks!
Thanks, I ended up using this in my game last night.
1571609818
The Aaron
Roll20 Production Team
API Scripter
Sweet!  Was it sufficient for your needs, or are there changes you want?
Hmm... it worked pretty well, I think the only thing I can ask for is being able to put a player's name in or character's name in and having it do the ping/move since constantly clicking tokens and moving my own screen to them got tedious after a while. If I could just write, !pull-players PLAYER_NAME then it would be perfect.
1571634760
The Aaron
Roll20 Production Team
API Scripter
Where would that pull the players to?  Currently, it uses the location of the selected tokens. I could have it find the first token on a page controlled by each player and pull them to it. 
1571634984
GiGs
Pro
Sheet Author
API Scripter
I think mAc is asking how to pull a players view to a token or object that they don't control. Pick a token, name a character, and have their view pulled to that token.
Oh, I meant pulling to the token they own, assuming they just own one as a player which is most situations. It just saves me the time of having to scroll over and click each token if they’re separated.
The VTT enhancement for Chrome does this as you run through initiative. It centers the screen over the token up in initiative and pings. A very handy set of functions in the Suite BTW.