
This script is primarily designed for use with a face to face gaming group that is using Roll20 on a shared screen like a tv or large computer monitor, whether it's flat on a table or on a desk/cabinet or wall. The script will remove the controlledby setting on the character sheets specified in the script which will show vision only for the token at the top of the turn order. Unless it is an npc or other token or custom item. In that case, it will return control of all the specified character sheets so that players can see something other than a black screen as the monsters move around on their turn and make attacks.
To specify which characters should have their controlledby settings toggled during combat, you need to get the character id of those characters. You can do this by selecting a token that represents that character and entering @{selected|character_id} in chat. You'll then copy and paste that information into a list at the top of the script.
When done properly, it should look exactly like the following, but with your character's ids...
var CharacterIDs = ["-KHWScTHo_oHinvteAqm", "-KGucJWiVEW9vZhF7_eM", "-KHWSkIxLWXyGIO5A4dJ"];
The script also adds a green dot to the token at the top of the turn order. This is required because otherwise the script won't force an update to the dynamic lighting until you click on the map or move a token.
Link to Video of the Script in Action: https://plus.google.com/+JonathanBlack/posts/5mV2ZaNp2Pj
To specify which characters should have their controlledby settings toggled during combat, you need to get the character id of those characters. You can do this by selecting a token that represents that character and entering @{selected|character_id} in chat. You'll then copy and paste that information into a list at the top of the script.
When done properly, it should look exactly like the following, but with your character's ids...
var CharacterIDs = ["-KHWScTHo_oHinvteAqm", "-KGucJWiVEW9vZhF7_eM", "-KHWSkIxLWXyGIO5A4dJ"];
The script also adds a green dot to the token at the top of the turn order. This is required because otherwise the script won't force an update to the dynamic lighting until you click on the map or move a token.
Link to Video of the Script in Action: https://plus.google.com/+JonathanBlack/posts/5mV2ZaNp2Pj
on("change:campaign:turnorder", function(current, previous) { var CharacterIDs = []; var CurrentTO = JSON.parse(current.get("turnorder")); var PreviousTO = JSON.parse(previous["turnorder"]); var Token; var Character; // Save F2F data... if (!state.f2f) state.f2f = {}; if (_.isEmpty(state.f2f)) { _.each(CharacterIDs, function(charid) { Character = getObj("character", charid); state.f2f[charid] = { CharacterID: charid, ControlledBy: Character.get("controlledby") } }); } // Process the turn order... if (CurrentTO.length > 0) { _.each(state.f2f, function(a) { getObj("character", a["CharacterID"]).set("controlledby", ""); }); if (CurrentTO[0].id != -1) Token = getObj("graphic", CurrentTO[0].id); if (CurrentTO[0].id != -1 && Token.get("represents") !== "") Character = getObj("character", Token.get("represents")); if (CurrentTO[0].id != -1 && Token.get("represents") !== "" && Character.id in state.f2f) { Character.set("controlledby", state.f2f[Character.id]["ControlledBy"]); } else { // Return control to all players during npc and custom item turns... _.each(state.f2f, function(b) { getObj("character", b["CharacterID"]).set("controlledby", b["ControlledBy"]); }); } } else { // Turn order tracker is empty. Return control to all players... _.each(state.f2f, function(z) { getObj("character", z["CharacterID"]).set("controlledby", z["ControlledBy"]); }); state.f2f = {}; } // Simple Initiative Tracker (Green Dot)... if (CurrentTO.length === 0 && PreviousTO[0].id != -1) getObj("graphic", PreviousTO[0].id).set("status_green", false); if (CurrentTO.length > 0 && CurrentTO[0].id != -1) getObj("graphic", CurrentTO[0].id).set("status_green", true); if (PreviousTO.length > 0 && PreviousTO[0].id != -1) getObj("graphic", PreviousTO[0].id).set("status_green", false); });