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

Only active token has sight?

1437237098

Edited 1437237126
I'm playing a live game and using roll20 for maps and combat on a 50 inch tv. I'd like to make a script that removes sight from all tokens when inititive tracker is activated and only the token who's turn it is has sight so that instead of all players seeing everything for their turn they can actively see only what they can see. then when it's closed give sight back to all players. I'm 90% sure i can do this but if someone has something similar already built and I havn't found it, that could save me time/effort.
1437244102
vÍnce
Pro
Sheet Author
You might use a script like Aaron's TokenMod or Torch to accomplish this. Aaron might even think-up a "magic trick" so that the sight toggles using the turn tracker as well...
1437248951
Ziechael
Forum Champion
Sheet Author
API Scripter
It's more of a workaround until someone *cough* Aaron *cough* gets back from LARPing but you could just select the active token and use Ctrl+L (Cmd+L on mac) to 'see' as that token 'sees'. It should remove all other sight-lines and give you the effect you are looking for with little manual effort.
the CTRL L thing only works when logged in as GM which means the whole map is exposed. I use 2 accounts so that they don't see all the extra stuff going on.
1437261484
Ziechael
Forum Champion
Sheet Author
API Scripter
Milo Tealeaf said: the CTRL L thing only works when logged in as GM which means the whole map is exposed. I use 2 accounts so that they don't see all the extra stuff going on. Gah, so it does... API it is then, i'm sure someone with those skills will be along soon enough
i've actually pretty much figured it out. I can change the has sight option of the active person on the initiative tracker. I'm just having a small issue finding out how to select all tokens to change the sight option to off. Once i can find a command that works similar to getAllObjs() that will select all tokens on a page instead of everything everywhere it'll be easy to cycle through them and change the sight
Nevermind, the script for that was just above the Getallobjs() in the wiki.....I'm a failure
1437265351

Edited 1437265413
It looks like to determine the token with initiative, you need to call the Campaign().get('turnorder') property and then set all tokens but the one with the current turnorder to light_hassight = false
I'm referencing this page: <a href="https://wiki.roll20.net/API:Objects#Graphic_.28Token.2FMap.2FCard.2FEtc..29" rel="nofollow">https://wiki.roll20.net/API:Objects#Graphic_.28Token.2FMap.2FCard.2FEtc..29</a>
1437266650

Edited 1437403980
I've pretty much got it working correctly, the only part that doesn't work currently is the call when the turn order is closed....Here's what i got so far. // VARIABLE & FUNCTION DECLARATION var TurnOrderSight = TurnOrderSight || {}; var AllSightOn = AllSightOn || {}; var AllSightOff = AllSightOff || {}; on("change:campaign:turnorder", function(obj) { TurnOrderSight(); }); on("change:campaign:initiativepage", function(obj) { if(obj == false) { AllSightOn(); }; }); function TurnOrderSight () { if (!Campaign().get("turnorder")) { AllSightOn (); return; }; var turn_order = JSON.parse(Campaign().get("turnorder")); if (!turn_order.length) { AllSightOn (); return; }; // Exit script if custom item on turn order tracker instead of a token... if (turn_order[0].id == -1) return; AllSightOff (); var current_token = getObj("graphic", turn_order[0].id); current_token.set({ "light_hassight": true, }); }; function AllSightOn () { var currentPageGraphics = findObjs({ _pageid: Campaign().get("playerpageid"), _type: "graphic", _subtype: "token", }); _.each(currentPageGraphics, function(obj) { //Do something with obj, which is in the current page and is a graphic. obj.set({ "light_hassight": true, }); }); }; function AllSightOff () { var currentPageGraphics = findObjs({ _pageid: Campaign().get("playerpageid"), _type: "graphic", _subtype: "token", }); _.each(currentPageGraphics, function(obj) { //Do something with obj, which is in the current page and is a graphic. obj.set({ "light_hassight": false, }); }); };
1437404214
The Aaron
Pro
API Scripter
I'd suggest adding some logging to your AllSightOn() function to verify it is getting called I'm pretty certain that this code is incorrect: on("change:campaign:initiativepage", function(obj) { if(obj == false) { AllSightOn(); }; }); When the event triggers (if initiativepage changes), it will pass you the full campaign object, not the property. It should likely be: on("change:campaign:initiativepage", function(obj) { if( obj.get('initiativepage') === false ) { AllSightOn(); }; });