Updated Dynamic Lighting API Support

Updated Dynamic Lighting is the new system for Dynamic Lighting and Advanced Fog of War. It features a stronger framework for future feature enhancements, is more performative, and has been updated for more current computing technologies. As this is a feature for Plus and Pro subscribers, if you'd like to try it out for yourself, please consider upgrading your account.

  Free

Plus

Pro
Updated Dynamic Lighting  

 



Updated Dynamic Lighting has API support at launch. Here are the details:

  • Token Settings:

    • has_bright_light_vision - Turns on Vision for the token. Use the booleans true to turn on or false to turn off. There is currently no available range to set for Vision.

    • has_night_vision - Turns on Night Vision for the token. Use the booleans true to turn on or false to turn off. You are able to set the range for this value using the next value.

    • night_vision_distance - Sets the range of night vision for the token. This is an integer.

    • emits_bright_light - Turns on bright light emitting from a token. This would be useful for a bonfire or a source with a lot of light. Use the booleans true to turn on or false to turn off.

    • bright_light_distance - Sets the range of the amount of bright light emitting from a token. This is an integer.

    • emits_low_light - Turns on low light emitting from a token. This would be useful for a torch or a source with a low amount of light. Use the booleans true to turn on or false to turn off.

    • low_light_distance - Sets the range of the amount of low light emitting from a token. This is an integer. When setting this value, you must include any Bright Light Distance you have set. The reason for this is because Low Light Distance is calculated from the center of the token. So if you have set Bright Light Distance to 10, and you would like an additional 10 feet of Low Light Distance, the value of low_light_distance must be 20.

  • Page Settings:

    • dynamic_lighting_enabled - Turns on the Updated Dynamic Lighting for the Page. Use true to turn on or false to turn off.

    • daylight_mode_enabled - Assumes that dynamic_lighting_enabled is enabled. This should not be turned on if dynamic_lighting_enabled is not turned on. Use the booleans true to turn on or false to turn off. Adds Light to the whole Page, good for a sunny day or well-lit room, or for GMs who don’t want to place light sources. Previously called “Global Illumination.”

    • explorer_mode - Assumes that dynamic_lighting_enabled is enabled. 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. Reveals areas of the Map Layer that players have explored. Does not reveal areas that were revealed when Explorer Mode is disabled. Previously called “Advanced Fog of War.”

  • Examples:

    • on("change:graphic", function(obj) {
        obj.set({
          has_bright_light_vision: true,
          emits_bright_light: true,
          bright_light_distance: 10
        });
      });
      • This will add the above values to a token in two instances:

        • upon adding a new token to the VTT

          • https://gyazo.com/7813e2b37a6c0c31439e045c64349af0

            • As you can see in this gif, a new image is dragged onto the VTT from the user’s Recent Uploads, there are NO default settings set for the campaign, so the API is effecting the new token so it has the three new settings.

        • moving a token that already exists on the VTT, with or without token settings already set.

      • HOWEVER, using on(“change is dangerous because if you update the token settings for a specific token, that triggers a change event, which will trigger this API. So, if you have something like this in your API script, your token settings will always stay this way for every token, unless you add some conditional statements so it works the way you want.

    • on("change:graphic", function(obj) {
        obj.set({
          has_bright_light_vision: true,
          emits_bright_light: true,
          bright_light_distance: 10,
          emits_low_light: true,
          low_light_distance: 25
        });
      });
      • This example will set Vision to any token that has changed (moved, updated, added to the VTT, etc). The token will also emit 10 feet of Bright Light Distance, as well as 15 feet of Low Light Distance.

        • Notice how low_light_distance is set to 25. That is because the value of low_light_distance must be the sum of bright_light_distance and however much you would like the token to emit Low Light Distance - in this case it is 15.

Was this article helpful?
1 out of 4 found this helpful