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

[Request] Initiative based Character Sight

Hey All, I'm starting to get into in-person tabletop gaming, and I was wondering if someone would be able to help me with an API script idea to aid in using Roll20 for in-person games.  The plan is to run everything off of my laptop, with one screen logged in as the GM, and another screen logged in playing as a player, under the same account (I already tried using 2 accounts, but it's not very stable).  For general exploring of the map, I'm planning on using a "Party" token, so they can move together as a group.  But for combat, I'll use individual tokens for each player. What I'd like to have happen is whoever's turn it is, you can only see what that player sees.  When I advance the Initiative tracker, it would automatically switch the sight to the next player's token.  If it is a mob's turn, all of the PC token's sights are turned on, so everyone at the table can see what's happening. I already use TokenMod in my campaign, if that makes editing tokens easier.  I also realize that having a preset list of tokens that the script will track might mean those tokens will have to be written into the script, that's fine, as long as it's not difficult to update that list.  I'm guessing that it would be easiest to have the script toggle the "Has Sight" option, instead of changing the light radius and dim, since that might be different for each token.  Though that would make it difficult for the DM to ctrl-L to see what that token sees. -Andrew
Ugh, I did some testing with Token-Mod using macros.  Toggling "Has sight" does work, but since everything is being viewed by the same "player", I can always see everyone's light, even when the token isn't supposed to.  I'm going to see if switching the "represents" option between the main character sheet and a 'null' character sheet will work...
1438732089
Ziechael
Forum Champion
Sheet Author
API Scripter
You'll need to remove any emitted light from other players unless the 'active' player would be able to see it too (a lantern for example), coupled with 'hassight|false' should give you the effect you are looking for using the tokenmod macro system.
Yeah, I've moved on from trying to edit the light settings, because I'd rather not have to bake all of the token's light settings into every script.  Now I'm having my own set of troubles trying to switch tokens between their own character sheets (that I have set to be controlled by me), and a Null character sheet (that is controlled by no one).
1438744629

Edited 1438744674
Better idea... Use an invisible token and move that to whichever token is at the top of the order and then center the view on that token. The invisible token should be the only one that has 'Has Sight' checked.
All light settings would be on the actual character tokens and no lights on the invisible token.
1438745925
The Aaron
Pro
API Scripter
HB, that's a pretty good idea.  If you're using my TurnMarker script, you could just put has site on its marker. That would be a partial solution. Doesn't get you all sight on Mook turns, and gives you site on Mook turns, but you could try it and see.
Thanks HB and The Aaron for your suggestions, I did a quick mock up to test your suggestion: Both Jack and Dan have Darkvision (60 feet, 0 dim).  The Light token is the only token with "Has Sight" selected, and all of the tokens can be controlled by the player.  In the above image, it is Jack's turn and we can see what he sees because the Light token has sight while next to him. I advance the tracker to Dan: The Light token moves to Dan, and we're able to see what he sees, no problem. The problem's arise when Jack and Dan are in the same room: It's Jack's turn again, so the Light token is next to him, but Dan's token is now down the hall from him.  We can see the light cast by Dan because both tokens are assigned to be controlled by the player, even though Dan's token isn't set to "All players see light". So unfortunately, that suggestion will not work, and I'm back to trying to write macros to toggle a token between representing multiple character sheets, so that the player can't see through the token when it's not that token's turn.  And if you saw my other post The Aaron, I'm having my own problems with TokenMod.
1438815663

Edited 1438815763
Um... that is exactly how it should work. If they're in the same room, the light by Dan will fill the room too and Jack would see that unless there's some magical shenanigans going on. Edit - Ah, didn't see the Darkvision part. Hrm.
If all tokens are going to be controlled by the same "player" and you want to essentially recreate different player views, then you'll probably have to manage "has sight" and any light that isn't visible to everyone.  The good news is that you don't have to encode that information in your script.  Instead, I'd suggest something along these lines: Whenever a token is added to the tracker, or if it's in the tracker when the script loads or the tracker opens, and whenever its turn ends, dump its sight and private light settings into state, then clear them on the token. Whenever a token is removed from the tracker, or if it's not in the tracker when the script loads or the tracker opens, and whenever its turn comes up in the tracker, restore its sight and private light settings from state, then clear them in state. This should work out such that when the tracker is open, only the token at the top will have sight or private light, and every other token's settings will be in state.  When the tracker is closed, everyone's sight and light should be restored.
manveti said: If all tokens are going to be controlled by the same "player" and you want to essentially recreate different player views, then you'll probably have to manage "has sight" and any light that isn't visible to everyone.  The good news is that you don't have to encode that information in your script.  Instead, I'd suggest something along these lines: Whenever a token is added to the tracker, or if it's in the tracker when the script loads or the tracker opens, and whenever its turn ends, dump its sight and private light settings into state, then clear them on the token. Whenever a token is removed from the tracker, or if it's not in the tracker when the script loads or the tracker opens, and whenever its turn comes up in the tracker, restore its sight and private light settings from state, then clear them in state. This should work out such that when the tracker is open, only the token at the top will have sight or private light, and every other token's settings will be in state.  When the tracker is closed, everyone's sight and light should be restored. Yes, this script would be specifically for in-person games.  My current setup for D&D Encounters is to use 2 chromebooks, one logged in as the GM, and a second as the player, with the screen mirrored to a display facing the players.  For now everyone is able to see what all the player characters can see, which works, but it's not ideal for determining line of sight and cover.  I end up using Ctrl+L on my screen to double check things. Would it work to have the script also check the character sheet to see what the value of the attribute "is_npc"?  Then if there is a token at the top of the initiative that is an NPC, then it restores the sight of all characters that are not NPCs.
1440640697
The Aaron
Pro
API Scripter
A script could check such an attribute.  I would suggest reversing the sense of the notation and instead only have the script active if the character has is_pc. There are likely fewer pcs than NPCs so it's less work. 
Well I'm using the Shaped 5e character sheets right now, so is_npc is the attribute tied to whether the sheet is using the player sheet or npc sheet.  But if I were to use a generic attribute that would be the preferable method. Alright, now I just need to read up on the API and lean on my friends who know Javascript. :D
1440702872
The Aaron
Pro
API Scripter
=D Lean on!
Andrew, check out my initiative highlighter script and you should be able to cannibalize it for the majority of what you need. All you'd really need to add is an if statement checking for the attribute and then making the light/vision changes on that token as needed.
I'm working through reading your highlighter script, but in the mean time I put together a simple flow description of what the code would do: When a token is added to the initiative tracker that has the attribute is_npc = 1: store the token's light info to state (based on the token_id) set all light info to null If a token has the attribute is_npc = 0, then store the token_id in an array When a token is at the top of the initiative: Check the attribute is_npc: if the attribute is 0, then load the light info from state if the attribute is 1, then load the light info of all tokens stored in the array to their respective tokens When the token leaves the top of initiative, store the light info to state and set all light info to null When a token is removed from initiative, restore the light info of the token from state