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

Macro Request : Transforming Bright light to dim light

I run a game where my team is going through shadowfell.  In there Bright light turns dim, an,d dim light turns dark.  Is there an already existing macro that can automatically switch UDL parameters following this ? For example a macro that would switch a torch going from 20ft nright light and 20 feet dim light to a 0 bright light and 20 dim.  Ideally it would only convert any value (what is bright becomes dim and what is dim is down to null. I have access to pro, so macros or mods are both available. Thanks for pointing the right direction to me if it already exists.
1701373536
The Aaron
Roll20 Production Team
API Scripter
You don't need to be able to revert this change, right?  And is operating on all light sources on the given page sufficient?  UDL only is fine?
1701374113
The Aaron
Roll20 Production Team
API Scripter
Here's my first pass solution.  Moves bright light radius to low light radius and turns off bright light emitting.  Does all tokens on the page. !bright-to-dim Code: on('ready',()=>{ const getPageForPlayer = (playerid) => { let player = getObj('player',playerid); if(playerIsGM(playerid)){ return player.get('lastpage') || Campaign().get('playerpageid'); } let psp = Campaign().get('playerspecificpages'); if(psp[playerid]){ return psp[playerid]; } return Campaign().get('playerpageid'); }; on('chat:message',msg=>{ if('api'===msg.type && /^!bright-to-dim(\b\s|$)/i.test(msg.content) && playerIsGM(msg.playerid)){ const who = (getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname'); let pageid = getPageForPlayer(msg.playerid); if(pageid){ let tokens = findObjs({pageid,type:'graphic'}); let adjusted = tokens.length; const burndown = ()=>{ let t=tokens.shift(); if(t){ let dim = t.get('bright_light_distance')||0; t.set({ bright_light_distance: 0, emits_bright_light: false, low_light_distance: dim }); setTimeout(burndown,0); } else { sendChat('',`/w "${who}" <div>Adjusted <code>${adjusted}</code> tokens.</div>`); } }; burndown(); } } }); });
Thanks you o-everly-quick-and-efficient Aaron !!! lol Actually it would be better to do that on selected token(s) as it doesn't really affect elves' darkvision...
1701376087
The Aaron
Roll20 Production Team
API Scripter
This doesn't affect darkvision, that's under the night_vision settings.  This only affects emitted light.
1701376127
The Aaron
Roll20 Production Team
API Scripter
But I can adjust it to do selected tokens easily enough.
1701376170

Edited 1701376427
The Aaron
Roll20 Production Team
API Scripter
Here's a version for selected tokens only: on('ready',()=>{ on('chat:message',msg=>{ if('api'===msg.type && /^!bright-to-dim(\b\s|$)/i.test(msg.content) && playerIsGM(msg.playerid)){ const who = (getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname'); let tokens = (msg.selected || []) .map(o=>getObj('graphic',o._id)) .filter(g=>undefined !== g) ; let adjusted = tokens.length; const burndown = ()=>{ let t=tokens.shift(); if(t){ let dim = t.get('bright_light_distance')||0; t.set({ bright_light_distance: 0, emits_bright_light: false, low_light_distance: dim }); setTimeout(burndown,0); } else { sendChat('',`/w "${who}" <div>Adjusted <code>${adjusted}</code> tokens.</div>`); } }; burndown(); } }); }); Edit:  Simplified a bit.
Nice !!! thank you sir !
1701390503
timmaugh
Pro
API Scripter
Anyone in the market for a little metascript magic? If you prep your tokens properly, you don't even have to select them. For instance, put the term "IsPartyToken" somewhere in the GM Notes field of the party tokens... then you can select the party automagically using: {&select *, +gmnotes ~ IsPartyToken} So your full command would look like: !bright-to-dim  {&select *, +gmnotes ~ IsPartyToken} Then you don't have to actually physically select the tokens, so it's faster. Also, you wouldn't lose some other complex set of tokens you maybe already had selected on the VTT because you were going to have to select the party to run this command. Instead, you can just run the command. Don't forget, if you like this and it works for you, to update the default tokens to the character sheet, again, so they come in with the notes already prefilled. =D
1701400705

Edited 1701400888
vÍnce
Pro
Sheet Author
Meta-Magic™