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 .
×
Advertisement Create a free account

[Script,Snippet] DropTorch -- A little script that lets you and your players drop their light source on the ground.

1586407934
The Aaron
Forum Champion
API Scripter
Jon A.&nbsp; &nbsp;had a great idea for a script and asked me about it, so I created it. =D If a token has sight that other players can see, then you can select it (or a whole group) and run: !drop-torch The script will create a little torch token below each selected token, transfer the light radius, light dim radius, and light angle to it, and remove the same from the selected tokens.&nbsp; Tokens with light that isn't visible to other players (i.e. Darkvision or similar) are not changed and don't create a torch token. Note : This works with Legacy Dynamic Lighting (i.e. the Dynamic Lighting we've been using, not the new Updated Dynamic Lighting that's currently in public beta).&nbsp; I'll update this when the UDL API solidifies. Script: on('ready',()=&gt;{ const torchSrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/119704545/iEuLX30JcxYYqwE98nUmcg/thumb.png?158640249955" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/119704545/iEuLX30JcxYYqwE98nUmcg/thumb.png?158640249955</a>"; const dropTorch = (obj) =&gt; { if(obj.get('light_hassight') &amp;&amp; obj.get('light_otherplayers')){ let size = Math.min(parseFloat(obj.get('width')),parseFloat(obj.get('width'))); let torch = createObj('graphic',{ imgsrc: torchSrc, pageid: obj.get('pageid'), layer: obj.get('layer'), controlledby: 'all', width: size, height: size, left: obj.get('left'), top: obj.get('top'), light_otherplayers: true, light_angle: obj.get('light_angle'), light_radius: obj.get('light_radius'), light_dimradius: obj.get('light_dimradius') }); setTimeout(()=&gt;toBack(torch),50); obj.set({ light_angle: 360, light_radius: 0, light_dimradius: 0 }); } }; on('chat:message',(msg)=&gt;{ if('api'===msg.type &amp;&amp; /^!drop-torch(\b\s|$)/i.test(msg.content)){ (msg.selected || []) .map(o=&gt;getObj('graphic',o._id)) .filter(g=&gt;undefined !== g) .forEach(dropTorch) ; } }); });
1586413843
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Neat idea. I could have used it tonight.