
Here's a little script snippet I wrote to help with a problem. It just toggles global illumination / daylight mode on and off. It detects if UDL or LDL is in use, and sets the right thing.
!toggle-daylight
!toggle-daylight on
!toggle-daylight false
You can specify a parameter that will tell it to set to on or off explicitly. Omitting the parameter will just toggle it back and forth. You can use any of these for on: on, yes, y, true, t or any number other than 0. Anything else is treated as off.
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 && /^!toggle-daylight(\b\s|$)/i.test(msg.content) && playerIsGM(msg.playerid)){ let who = (getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname'); let pid = getPageForPlayer(msg.playerid); let page = getObj('page',pid); let args = msg.content.split(/\s+/); let isSet = false; let setValue = true; if(args.length>1){ isSet = true; setValue = ['on','yes','y','true','t'].includes(args[1].toLowerCase()) || ((parseInt(args[1])||0)>1); } let field = ''; if(page.get('dynamic_lighting_enabled')) { field = 'daylight_mode_enabled'; } else if(page.get('showlighting')) { field = 'lightglobalillum'; } if(field) { let curr = page.get(field); setValue = (isSet ? setValue : !curr); if(setValue !== curr){ page.set(field, setValue); sendChat('',`/w "${who}" Daylight set to ${setValue ? 'On' : 'Off'}`); } } else { sendChat('',`/w "${who}" Dynamic Lighting not in use on this page.`); } } }); });