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

Is there a pageMod tool?

September 04 (3 years ago)

I was looking for a tool that allows you to set page setting for map settings?  Sort of like the what the awesome "tokenmod" does for tokens? I want to create commands to setup default UDL settings (day, night, off)? Anyone know if something like this that exists?

September 04 (3 years ago)

Edited September 05 (3 years ago)

I create a simple API script to set the light levels... it is not the most elegant but given a command I can set day, night, moonlight, dusk and off :)

here are the command

!daylight day

!daylight night

!daylight dusk

!daylight moonlight

!daylight off

*EDIT: fixed issue with explorerMode to basic. Thanks Jens

on('ready',function() {
    "use strict";

    if( state.daylight){
        state.daylight = {
            version: 'v1.0'
        };
    }
    log('-=> Loading Daylight '+ state.displayMarkers.version);

});

on('chat:message',msg=>{
    if(msg.type === 'api'){
        if (msg.content.split(' ')[0].toLowerCase() === '!daylight'){
            let page = getObj('page', Campaign().get('playerpageid'));
            
            if (msg.content.split(' ')[1].toLowerCase() === 'dusk') {
                
                page.set('dynamic_lighting_enabled',true);
                page.set('daylight_mode_enabled', true);
                page.set('explorer_mode','basic');
                page.set('lightupdatedrop',true);
                page.set('daylightModeOpacity',0.5);
                page.set('force_lighting_refresh',true);
                sendChat('daylight','The sun peaks over the horizon');
            } else if (msg.content.split(' ')[1].toLowerCase() === 'day') {
                
                page.set('dynamic_lighting_enabled',true);
                page.set('daylight_mode_enabled', true);
                page.set('explorer_mode','basic');
page.set('lightupdatedrop',true); page.set('daylightModeOpacity',1.0); page.set('force_lighting_refresh',true); sendChat('daylight','The Sun is blazing in the sky'); } else if (msg.content.split(' ')[1].toLowerCase() === 'night') { page.set('dynamic_lighting_enabled',true); page.set('daylight_mode_enabled', true); page.set('explorer_mode','basic');
page.set('lightupdatedrop',true); page.set('daylightModeOpacity',0.0); page.set('force_lighting_refresh',true); sendChat('daylight','The dark of night falls'); } else if (msg.content.split(' ')[1].toLowerCase() === 'moonlight') { page.set('dynamic_lighting_enabled',true); page.set('daylight_mode_enabled', true); page.set('explorer_mode','basic');
page.set('lightupdatedrop',true); page.set('daylightModeOpacity',0.2); page.set('force_lighting_refresh',true); sendChat('daylight','The moon shines bright'); } else if (msg.content.split(' ')[1].toLowerCase() === 'off') { page.set('dynamic_lighting_enabled',false); page.set('daylight_mode_enabled', false); page.set('explorer_mode','off'); page.set('lightupdatedrop',false); page.set('daylightModeOpacity',0.0); page.set('force_lighting_refresh',true); sendChat('daylight','Turning off UDL'); } } } });
September 04 (3 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

That's a really handy little script!

September 05 (3 years ago)

Ooh I’m giving this a try great work

September 05 (3 years ago)

opps there is a mistake in the script.... page.set('explorer_mode','no'); should be page.set('explorer_mode','on'); :) sorry about that I just swa that. I will fix it quic and post a link

September 05 (3 years ago)

Edited September 05 (3 years ago)
Jens
Pro

I had to change 'on' to 'basic' to get the explorer_mode to be set to on.

September 05 (3 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

From the API objects page:

explorer_mode String Toggles explorer mode for the page. This should not be turned on if dynamic_lighting_enabled is not turned on.
Use the strings ”basic” to turn on or ”off” to turn off.

which is interesting, since it implies other states.

September 05 (3 years ago)

Opps you are correct Jens....I updated it above.

September 05 (3 years ago)

Thanks for the script Craig! A really handy option to have available on the fly. I quickly threw together a simple macro for your commands:

!Daylight ?{Light Level|day|night|dusk|moonlight|off}
September 11 (3 years ago)

Thank you for the script Craig  and the macro Sam B, both came in very handy.