Advertisement Create a free account

[Script] ShareVision (Formerly: Party Sight)

1460300114

Edited 1460677741
Scott C.
Forum Champion
Sheet Author
API Scripter
The original reason behind this script. I have a particularly rowdy bunch of players (or really just one instigator) that like to be annoying during downtime and talk in chat as other people's characters (particularly the paladin's horse for some reason) and move tokens weirdly (again the paladin's horse for some reason). I had everyone as controlling all player tokens so that when a battle or other encounter broke out in a hallway or house or some such thing people could actually figure out what was going on without me or the person who could see it spending a bunch of time describing exactly what was where, but I've switched back to each character only being controlled by the actual player it represents due to the hijinks above. Is there some way I could use the API to temporarily give the party access to a given character(s)'s sight? I'm thinking something like The Aaron's torch script but giving sight instead of light and maybe have it be activated by a status marker (say the eye) being placed on a token. I have absolutely zero clue how to code, but I'm willing to learn if someone can give me some ideas. V0.1.4 update (<a href="https://gist.github.com/Kurohyou/7b0c2485972e15520957d4cf16bdd97a" rel="nofollow">https://gist.github.com/Kurohyou/7b0c2485972e15520957d4cf16bdd97a</a>): Darkvision sharing was not working properly; changed the function so that having the aura marker active triggers the normal vision sharing. Activating the overdrive marker activates Darkvision sharing. Darkvision sharing overrides the normal vision sharing, so having both markers active results in Darkvision sharing (but not two children tokens being made). Previous Version: I have updated the script so that you can now pass the light radius and dim radius of the parent token to the child token. This will not pass the "can all player's see light" status as that seemed redundant. This does allow you to share darkvision with the party if you so choose. In order to trigger this simply use the 'overdrive' status marker (1st status in the 4th row of markers, looks like a bladestorm)&nbsp;in addition to the 'aura' status marker . This will trigger the script to get the light radius and dim radius values from the parent. If only the 'aura' marker is active, it will function as before; if only the 'overdrive' marker is active, there is no effect. If you no longer want Darkvision to be shared, but still want normal vision shared you will need to remove both status markers and reapply only the 'aura' marker. -Scott C.
1460304990
The Aaron
Forum Champion
API Scripter
I think there is a good solution to your problem. &nbsp;Several of my scripts use invisible follower tokens (Torch's flickers, Bump, Facing). &nbsp;Probably I'd suggest making a script that lets you toggle on a follower for players which has sight, is controlled by all players, pushed to the back below tokens, and undoes any changes made to it so that it always just stays where it's suppose to be granting sight to the other players. I don't have time to write it right now (prepping for my sunday game, working on a rewrite), but I can help you with it or work on it later. &nbsp;I'd suggest using Facing as a base, but have it create the image that Bump and Torch use (clear 1x1 gif). &nbsp;Then it's just a matter of juggling the layers and players on it.
1460305847
Ziechael
Forum Champion
Sheet Author
API Scripter
Also, if it is generally during downtime that the players like to 'have fun' (damn them) I would highly recommend a splash page that you can put the player ribbon on between sessions... i often include things like a drawing board, some tokens for testing macros or just messing about etc.
1460318183
Scott C.
Forum Champion
Sheet Author
API Scripter
Thanks Aaron, that was sort of what I was thinking, it's nice to know i wasnt too far off base. I'll take a look at facing and see what I can do. Thanks for the suggestion Ziechael. I've got a downtime splash page for between games, but it's during rules lookups and what not that I'm more worried about.
1460384810
Scott C.
Forum Champion
Sheet Author
API Scripter
So, working on this, I'm trying to figure out how to set the controlledby property. The API wiki says that it should be a comma-delimited list of players. What I'm wondering is if 'All Players' is a valid entry, or what entry I could use for that. I'm assuming it is valid in some form since it is a possible entry in the controlled by field of tokens/characters.
1460386969

Edited 1460386993
The Aaron
Forum Champion
API Scripter
All players is represented by 'all' in the controlledby field, something like this might be possible: "all,-JZ1234s11234" Generally, you'll probably just want to do: token.set({ controlledby: 'all' }); Or specify it that way when creating the token.
1460387397
The Aaron
Forum Champion
API Scripter
I updated the documentation to include the all keyword in each place where it's approprtite.&nbsp;
1460421235
Scott C.
Forum Champion
Sheet Author
API Scripter
So, I've been trying to adjust Facing for this, but I keep generating syntax errors. I've got an unexpected identifier now. Not sure what that means.
1460422686
The Aaron
Forum Champion
API Scripter
It means you have something that isn't valid javascript. &nbsp; Try putting it in&nbsp; JS Lint , or in the&nbsp; Google Closure Compiler . &nbsp;See if they give you a better idea of the error (particularly the latter).
1460424416
Scott C.
Forum Champion
Sheet Author
API Scripter
ah, yes, google closure compiler is much more useful. Now, onward with the script. Thanks for all the help.
1460425835
The Aaron
Forum Champion
API Scripter
Btw, I hang out in the Gitter on my Repo if you want to chat about Coding: &nbsp; <a href="https://gitter.im/shdwjk/Roll20API" rel="nofollow">https://gitter.im/shdwjk/Roll20API</a>
1460471894
Scott C.
Forum Champion
Sheet Author
API Scripter
Thanks for that T'Aaron, I may look you up there later today as I'm not quite sure how to go forward with it. I got facing modified so that if I used !shareVision (changed facing to this) it would create a slave on the objects layer and the slave would have vision (this was the easy part of just adding controlled by and hassight to the created slaves attributes). I then tried to get it to respond to a change in a token's status markers instead of a chat command and now it's throwing a reference error on multiple lines. I'm not really sure what's going on. Anyways, I'll probably drop into Gitter after work tonight to see what you think. Thanks again for all the help.
1460474282
The Aaron
Forum Champion
API Scripter
Hahaha. That's almost the name of a mage I played in a Dungeon World Group. &nbsp;T'zarn, which was of course based on The Aaron. =D Sounds really neat, I can't wait to see it. &nbsp;So adding the status marker on a token would trigger the existence of the full vision follower? &nbsp;Sounds pretty neat. &nbsp;Reference errors like that are usually something pretty simple that's just obnoxious to track down. =D &nbsp;Lucian and some other scripters hang out in that chat as well, so there should be someone to chat with. =D
1460493752

Edited 1460494971
Scott C.
Forum Champion
Sheet Author
API Scripter
EDIT: Apparently it is not done. Will update when it works outside of a single campaign. Thanks to Aaron and Lucian I've finished the script, and so far it's been stable. The script watches for changes in tokens and if the aura status marker is added to the token creates an invisible slave token at the back of the objects layer that moves with the master token, has sight, and is controlled by all players. If the aura status marker is removed, the slave is deleted. Because the slave is controlled by all and on the back of the layer, anyone who does not control the master token will be able to select the slave token and move it, however it repositions itself to match the master token as soon as it is dropped (thanks to the slave:master coding from the Aaron's Facing script); it can however be deleted accidentally. <a href="https://gist.github.com/Kurohyou/7b0c2485972e15520957d4cf16bdd97a" rel="nofollow">https://gist.github.com/Kurohyou/7b0c2485972e15520957d4cf16bdd97a</a> Thank you again to Aaron for all his help and the basic code structure, Scott C.
1460494917
Silvyre
Forum Champion
Congrats, Scott C. ! I'll be looking forward to trying this out!
1460495067
Scott C.
Forum Champion
Sheet Author
API Scripter
Unfortunately Silvyre, it appears to only work in the campaign I designed it in, and is returning various undefined variables in my active campaign. I'll work on it some more tonight to see if I can't figure out what is going wrong/ask Aaron to take a look and take advantage of some more of his help.
1460495371
Silvyre
Forum Champion
No worries! Worst case scenario, I'll nag The Aaron until he agrees to help adapt me it to my own future game. Good luck!
1460501685
Scott C.
Forum Champion
Sheet Author
API Scripter
ok, now it should work. I apparently needed to put back in some of the things I had taken out, thinking they weren't needed. Thanks go again to Aaron for his masterful debugging skills. <a href="https://gist.github.com/Kurohyou/7b0c2485972e15520957d4cf16bdd97a" rel="nofollow">https://gist.github.com/Kurohyou/7b0c2485972e15520957d4cf16bdd97a</a> Let me know if anything isn't working.
1460506218
The Aaron
Forum Champion
API Scripter
This is a great idea and I think there are some other great opportunities for its use, particularly since only the follower grants sight but stays fixed to the token. &nbsp;Clairvoyance, scrying, exposition... &nbsp; Like it. &nbsp;=D
1460519842
Scott C.
Forum Champion
Sheet Author
API Scripter
Heh, hadn't thought of those, but yeah it would.
1460661002
Scott C.
Forum Champion
Sheet Author
API Scripter
Updated the script with the ability to share Darkvision
1460675754
The Aaron
Forum Champion
API Scripter
Ooh! &nbsp;Great addition!