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

Center on Token at the Top of the Turn Order

on('chat:message', function(msg) { if(msg.type != 'api') { return; } var selected = msg.selected; if( msg.content.indexOf("!center") === -1 || !selected ) { return; } turnOrder=TurnOrder.Get(); if(turnOrder[0].id == marker.id) { return; } current = _.first(TurnOrder.Get()); var currentToken = getObj("graphic", turnOrder[0].id); if(undefined != currentToken) { sendPing(currentToken.get("left"), currentToken.get("top"), Campaign().get('playerpageid'), null, true); } }); What am I missing?
Just fyi, this will likely center the map on any token... including tokens hidden on the GM layer and give away their locations.
Right, with the current GM only bug on the send ping, and even if it does ever get resolved, I am just looking to get this to work on medium to large scale fights where the next token in the turn order for me the DM/GM isn't on my screen. I was testing with it in Aaron's turn order script, where it would automatically do it on turn order change, but that coupled with giving the players the ability to end their own turn with a macro caused an issue where I would be changing the health of something that took damage, and a player would end their turn and it would pull my selection off of what I had selected, and center my screen on the next in line. By attempting to get it separated, I can only use it when I really need it. I actually would like this to do stuff hidden on the GM layer, and also center for players whenever it is fixed. As I would love to use it as a tool to show, "you hear movement in this direction". "An arrow was fired from over here".
1411658665

Edited 1411659321
The Aaron
Roll20 Production Team
API Scripter
You could provide an api command that does this, and then just click it if you want to zoom to a token? Not enough coffee yet today to power my reading skills... Thoughts as comments inline: on('chat:message', function(msg) { if(msg.type != 'api') { return; } var selected = msg.selected; if( msg.content.indexOf("!center") === -1 || !selected ) { return; } turnOrder= TurnOrder .Get(); // <-- TurnOrder doesn't seem to be defined. (turnOrder should have a var in front of it) // You're probably piggybacking off of the Object I defined in my script? if(turnOrder[0].id == marker .id) { // marker is the variable in my TurnMarker script.. this will probably be an error return; } current = _.first(TurnOrder.Get()); // this could just be _.first(turnOrder) var currentToken = getObj("graphic", turnOrder[0].id); if(undefined != currentToken) { sendPing(currentToken.get("left"), currentToken.get("top"), Campaign().get('playerpageid'), null, true); } });
1411663208

Edited 1411663904
Sounds like I should be good to test this then? on('chat:message', function(msg) { if(msg.type != 'api') { return; } var selected = msg.selected; if( msg.content.indexOf("!center") === -1 || !selected ) { return; } var current = .first(turnOrder); var currentToken = getObj("graphic", current.id); if(undefined != currentToken) { sendPing(currentToken.get("left"), currentToken.get("top"), Campaign().get('playerpageid'), null, true); } });
1411665625
The Aaron
Roll20 Production Team
API Scripter
There's and underscore before the .first: var current = _.first(turnOrder) Other than that, it should be fine. You should really put code in the code format so that it's easier to read.
1411667002

Edited 1411667021
Learn something new every day. var current = _.first(turnOrder) Excellent, thank you!
1411668167
The Aaron
Roll20 Production Team
API Scripter
np.