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] script to change token vision range

is there a script that can lower a tokens vision to 5 feet. i would like to use it for fun maze puzzles, or to prevent meta in fog spells. i was thinking something tied to the blinded status icon, or any status icon would be super cool so you could easily go back and forth between 5 feet vision and normal, thanks!
1416517773
The Aaron
Roll20 Production Team
API Scripter
As in, change the light radius? <a href="https://app.roll20.net/forum/post/1104897/script-t" rel="nofollow">https://app.roll20.net/forum/post/1104897/script-t</a>... Set light to bright for 5 feet, that cuts out immediately: !torch 5 5 on @{target|token_id} Set light to bright for 30 feet, 15 dim: !torch 30 15 on @{target|token_id} So long as you're using dynamic lighting, that will work.
1416517946
The Aaron
Roll20 Production Team
API Scripter
If you aren't otherwise using dynamic lighting, this can still work, you'd just need to give everyone not restricted by the fog a huge radius of light that only they can see: !torch 1000 1000 off @{target|token_id} You can toggle dynamic lighting on with that script as well: !nighttime !daytime
hey thanks for answering. so i read the script and just wanted to make sure i understood. in order to change some tokens to 5 feet i would highlight all the tokens then type- !torch 5 5 on @{target|token_id} what do i put in for token_id? and also how can i easily change it when the pc leaves the fog, or do i need to ask the player for their vision and resuse the torch command? is there anyway that the token could be changed back to its normal vision easily
1416521302
The Aaron
Roll20 Production Team
API Scripter
You are pretty much correct. There are 3 options for how to do this: 1. !torch will affect any selected tokens: !torch 5 5 on 2. !torch will affect tokens who's token ids are specified: !torch 5 5 on -Jb8EyJkOiE9DRuWClpf -JbAHUfLBgXDyH8p1lXS -JbA6cc8b344nbMWsFOg 3. !torch like above, but with @{target|token_id}, etc to specify the token_ids: !torch 5 5 on @{target|Token 1|token_id} @{target|Token 2|token_id} @{target|Token 3|token_id} @{target|Token 4|token_id} (Note: if you have 4 @{target} commands, but only need to select 2 tokens, you can just select one multiple times, duplicates are removed.) So, if you don't mind selecting tokens, 1. above is quite easy. If you want to prep for changing the lights on specific tokens, you can use 2. If you want a macro that will prompt you for which tokens to change, use 3. Does that help?
thanks again for the quick reply. more follow ups heh - 1. so the 'on' means all players see the light from that token correct? so if i wanted to i could do !torch 5 5 off for selected tokens so they each get 5 feet of 'has sight' but cannot see each others light correct? 2. so it seems i can create a macro to quickly and easily return specific tokens to normal sight. i am guessing the easiest way to do that is option 2 or 3. do tokens need to be selected for these 2 options? also how do i set token id? so would the macro go - !torch 30 15 off @{target|Token 1|token_id} @{target|Token 2|token_id} @{target|Token 3|token_id} @{target|Token 4|token_id} but what do i write for Token 1 and toked_id, sorry i am super new to api, thanks again, this might be exactly what i was looking for.
1416529407
The Aaron
Roll20 Production Team
API Scripter
No problem. =D 1. The on does mean all players see light (You can actually use any of: '1','on','yes','true','sure','yup','-' for on, or anything else for off.). 2. Ok, a short API lesson then: Evaluation of Commands. When you type a command in chat, it goes through several stage (conceptually certainly, but if you think of the this way, it will help you understand), here they are: You type in the command and hit enter Everything in a @{...} or ?{...} gets evaluated. This means that either the @{...} is replaced by the attribute/target/selected value, or you are prompted for a value and the ?{...} is replaced with what you provide. Inline Rolls are evaluated, so all the [[...]] things that were typed are replaced with the results (conceptually) The message is sent to the API So, for example if you type in " !foo [[3+2d6+@{foo|hp}]] ", the API will see this as (roughly) " !foo 24 ". So, with that understanding, the API sees 2 and 3 in my examples above as the same thing. The only difference is where the arguments come from in steps 1 & 2 in the Evaluation of Commands . Also, the ?{target|...} syntax: @{target| &lt;stuff&gt; } will prompt you for a token to get &lt;stuff&gt; from. &lt;stuff&gt; can take two forms. It can either be an attribute (or pseudo-attribute) like bar1 or token_id , or it can be a label followed by an attribute: @{target|The token who you want to adjust|token_id} This will pop up the select box prompting you to select a token and display the message "The token who you want to adjust", then during step 2 above it will be replaced by the token's token_id. Additionally, if you use the same label multiple times, it will only be asked once and then used in all of the commands of a single macro/chat message: !cmd1 @{target|Foo|token_id} 1cmd2 @{target|Foo|token_id} This will only ask you once to select something. That's the reason the labels in the above are "Token 1", "Token 2" etc. Ok.. hopefully that actually added to your understanding... =D So, to your question: You can blend all 3 of my examples above happily. With a token selected, you can do: !torch 5 5 on -Jb8EyJkOiE9DRuWClpf @{target|Token 1|token_id} This will set the radius to 5 for the selected token, the token with token_id -Jb8EyJkOiE9DRuWClpf, and the token you select when prompted by the @{target|Token 1|token_id}. You have some options about what you want to do. If it's pretty easy for you to select (and you can select as many as you want) tokens, using example 1 will be pretty easy. If you want to be able to do several at once but don't want to select them first (maybe you only want to use the mouse and don't want to have to hold shift or whatever) you can use example 3. If you wanted to create a reset macro that always set your players tokens to 30' light, 15' dim, you could find their token_ids (just write @{target|token_id} in the chat and you'll have them), and write a macro with the syntax in example 2. Caveat though, token_ids are specific to individual tokens on a particular page. If a character has multiple tokens (say, across multiple pages), each one has it's own token ID, so this is really only useful in limited circumstances. Hopefully that clears it up... I'm a bit wordy.. sorry! =D
no no that was perfect! going to try it out and can let you know if there are issues, thanks!!!!!
do i need this for your script - IsGMModule
1416531704
The Aaron
Roll20 Production Team
API Scripter
Yes, and be sure to say something in chat as yourself (with the (GM) after your name) to let it detect you.
thanks! works perfectly, just tried it in game
1416535147
The Aaron
Roll20 Production Team
API Scripter
SWEEET!! Happy gaming! Let me know if you need anything else!