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 .
×

[Script] Updated Lights

Hey guys, Figured I'd share a little modification I did on the Lights script :  var lights = function(selected,radius,dim) {     _.each(selected, function(obj) {         var light = getObj("graphic", obj._id);         if(light.get('subtype') != 'token') return;         light.set("light_radius", radius);         light.set("light_dimradius", dim);     }); }; on("chat:message", function(msg) {     var parts = msg.content.toLowerCase().split(' ');     if(msg.type == "api" && msg.content.indexOf("!lite") !== -1) {       lights(msg.selected,parts[1],parts[2]);};}); on("chat:message", function(msg) {     var parts = msg.content.toLowerCase().split(' ');     if(msg.type == "api" && msg.content.indexOf("!dark") !== -1) {       lights(msg.selected,parts[1],parts[2]);};}); the changes to the commands are as follows : now sets the light values for all of the selected tokens , given that they are actually tokens the commands are now ' !lite X Y ' and ' !dark X Y ', these let you manually set the light radius and dim radius respectively in the command Let me know what you think, obviously its nothing special, but its already been a nice help for me. Kyle
1379978555
Lithl
Pro
Sheet Author
API Scripter
You don't need two copies of on('chat:message'). One will suffice. !lite and ! dark are doing the exact same thing. Some feedback I got on a similar script I posted (in the mentor forum if I recall): you have no means of turning the light off.
1380098680
Alex L.
Pro
Sheet Author
Brian said: You don't need two copies of on('chat:message'). One will suffice. !lite and ! dark are doing the exact same thing. Some feedback I got on a similar script I posted (in the mentor forum if I recall): you have no means of turning the light off. Don't forget there is no error handling at all, what if X and Y aren't valid values?