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

Simple Light Script to give tokens visibility and change their lighting quickly

I made a simple script that allows you to select a token and click a macro to set the light of that token. I had issues with using the lighting and found it time consuming to adjust it so i made this. For creating light and sight on characters make a macro and copy whats below. Set the macro as a token or "in Bar" remember a token needs to be selected for it to work. You can name the macro whatever u want. !CreateSight ?{Distance Falloff Others} For creating light. Useful for static objects. !CreateLight ?{Distance Falloff} Examples of Use for CreateSight So you can hit a macro button and go "30 15 y" and this would give a range of 30 feet and a dim at 15 and the y indicates that other players can see it. Useful for setting up a player with a torch. If you have a player with 30 foot darkvision you can go "30" and that will give him 30 feet of darkvision with no dim effect and other players can not see it. Perfect if they drink a potion of dark vision. Examples of Use for CreateLight If you want to setup a large light source, but do not want "has sight" checked you can use just !CreateLight [60 30 ] instead of !CreateSight. Mind you CreateSight can easily make a torch on a wall, CreateLight just automatically sets the value so others can see it and it doesnt have the toggle of "Has Sight" set to true. code is below on('chat:message', function (msg) { if (!(msg.selected && msg.selected.length > 0)) return; var token = getObj('graphic', msg.selected[0]._id); if (token.get('subtype') != 'token') return; if (msg.type == 'api' && msg.content.indexOf('!CreateSight') !== -1) { createLight(msg.content, token, true, false); } if (msg.type == 'api' && msg.content.indexOf('!CreateLight') !== -1) { createLight(msg.content, token, false, true); } }); function createLight(p, token, sight, visible){ var values = p.split(" "); if(sight === true){ token.set("light_hassight", true); } if(visible === true){ token.set("light_otherplayers", true); } if( is_int(values[1])) { token.set("light_radius", values[1]); } if(is_int(values[2])) { token.set("light_dimradius", values[2]); }else if(values[2]=="y"||values[2]=="Y"){ token.set("light_otherplayers", true); } if(values[3]=="y"||values[3]=="Y"){ token.set("light_otherplayers", true); } } function is_int(value){ if((parseFloat(value) == parseInt(value)) && !isNaN(value)){ return true; } else { return false; } }
I like it! Thanks a million!