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

Flickering Lighting or Map Image

Hi all, I am going to be doing a slightly horror themed section to my campaign and was any way to utilise an API for the Dynamic lighting or map that simulates a flickering light, so the players see the map for a random length of time and then just see darkness, essentially so ot simulates the flickering of broken lights. Thanks Aaron.
The Aaron’s  Torch Script  and David M’s  LightningFX  both have flickering light effects (I think the LightningFX is more what you’re looking for). Unfortunately those scripts only work for Legacy Dynamic Lighting, not Updated Dynamic Lighting. 
Thanks, I'll take a look into these.
This Script will flash bright light briefly: (From The Aaron, of course) Macro: !flash on('ready',()=>{   const FLASH_TIME = 300; // milliseconds   const getPageForPlayer = (playerid) => {     let player = getObj('player',playerid);     if(playerIsGM(playerid)){       return player.get('lastpage');     }     let psp = Campaign().get('playerspecificpages');     if(psp[playerid]){       return psp[playerid];     }     return Campaign().get('playerpageid');   };   const flash = (page) => {     if(page.get('dynamic_lighting_enabled') && !page.get('daylight_mode_enabled')){       page.set({daylight_mode_enabled: true});       setTimeout(()=>page.set({daylight_mode_enabled: false}), FLASH_TIME);     }   }   on('chat:message',(msg)=>{     if('api' === msg.type && /^!flash(\b\s|$)/i.test(msg.content) && playerIsGM(msg.playerid)){       let page = getObj('page', getPageForPlayer(msg.playerid));       if(page){         flash(page);         let who = (getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname');         sendChat('',`/w "${who}" ⚡ FLASH ⚡`);       }     }   });
1653995700

Edited 1653995887
David M.
Pro
API Scripter
Josh posted a UDL conversion method for the LightningFX script here .  Also, I'm pretty sure TheAaron posted a UDL lightning scriptlet somewhere that randomized the global illumination flash that al e. shared above. Can't seem to find it, but maybe he'll run across this thread. That would be the easiest method, as my LightningFX script requires setting up a sheet and placing tokens around, etc. The only advantage is that the lightning flashes from random locations giving it a spooky feel, but it's a bit fiddly tbh. I like Aaron's solution better.
1654003722
The Aaron
Roll20 Production Team
API Scripter
Hi Aaron, Here's the script I think David is talking about (thanks for the ping!): on('ready',()=>{ const scriptName = 'RandomLightFlash'; const version = '0.1.0'; const schemaVersion = 0.1; const lastUpdate = 1643732108; const CHANGE_MIN = 5; const CHANGE_MAX = 7; const EmitPattern = [[0,2.5],[2.5,5],[5,10],[5,5],[2.5,5],[0,2.5]]; const PHASE_DELAY = 100; const checkInstall = () => { log(`-=> ${scriptName} v${version} <=- [${lastUpdate}]`); if ( !state.hasOwnProperty(scriptName) || state[scriptName].version !== schemaVersion ) { log(` > Updating Schema to v${schemaVersion} <`); switch (state[scriptName] && state[scriptName].version) { case 0.1: /* break; // intentional dropthrough */ /* falls through */ case "UpdateSchemaVersion": state[scriptName].version = schemaVersion; break; default: state[scriptName] = { version: schemaVersion, options: {}, tokenMap: {} }; break; } } }; const flashToken = (t) => { t.set({ emits_bright_light: true, emits_low_light: true, }); let phases = [...EmitPattern]; const burndown = () => { let phase = phases.shift(); if(phase){ t.set({ bright_light_distance: phase[0], low_light_distance: phase[0]+phase[1] }); setTimeout(burndown,PHASE_DELAY); } else { t.set({ emits_bright_light: false, emits_low_light: false, bright_light_distance: 0, low_light_distance: 0 }); } }; burndown(); }; const checkTokens = () => { let now = Date.now(); Object.keys(state[scriptName].tokenMap).forEach(t=>{ if(state[scriptName].tokenMap[t].nextChange < now){ let token = getObj('graphic',t); if(token){ flashToken(token); state[scriptName].tokenMap[t].nextChange = now + (CHANGE_MIN + randomInteger(CHANGE_MAX-CHANGE_MIN))*1000; } else { delete state[scriptName].tokenMap[t]; } } }); }; let interval = setInterval(checkTokens,1000); on('chat:message',msg=>{ if('api'===msg.type && /^!toggle-flashing(\b\s|$)/i.test(msg.content) && playerIsGM(msg.playerid)){ let who = (getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname'); let now = Date.now(); (msg.selected || []) .map(o=>getObj('graphic',o._id)) .filter(g=>undefined !== g) .forEach(token=>{ if(state[scriptName].tokenMap.hasOwnProperty(token.id)){ delete state[scriptName].tokenMap[token.id]; } else { state[scriptName].tokenMap[token.id] = { nextChange: now + (CHANGE_MIN + randomInteger(CHANGE_MAX-CHANGE_MIN))*1000 }; } }) ; } }); checkInstall(); }); Just select tokens you want to have as your emitters and run: !toggle-flashing Those tokens will then begin emitting UDL flashes every 5-7 seconds. Cheers!
Thanks all. This should help cast an eerie feeling for the map :-)