Page 1 of 1

[ADD ON] D20 Light

Posted: Sat Nov 10, 2012 10:07 pm
by aliasmask
The idea is to quickly get a light that can be manipulated by the PCs and put it on the current map. Either during map design or on-the-fly.

This could be adapted for really any "type" of light (see Wiki: setLight()), but this one is specific to this framework and the lights under the D20 category.

The token contains an image of a lantern and has two macros on it. It is also owned by all and is not snapped to grid and tiny. You can put this token on your summon map or manually drag from library or cut/paste from another map.

Macros:
  • Set D20 Light - You chose which light source from your campaign lights in the D20 light type to be put on token (default Lamp - 15). Also set the light state to on or off.
  • Toggle D20 Light - This will switch the light on and off.
  • ||| MACROS |||

    Code: Select all

    @@ @<b>Toggle D20 Light</b>
    [H: lightState = 1 - getProperty("lightState")]
    [H: lightName = getProperty("lightName")]
    [H: setProperty("lightState",lightState)]
    [H: setLight("D20",lightName,lightState)]
    
    !!
    @@ @Set D20 Light
    [H: D20Lights = json.get(json.get(getInfo("campaign"),"light sources"),"D20")]
    [H: D20Lights = json.sort(D20Lights,"a","name")]
    [H: lights = ""]
    [H: lightNames = ""]
    [H, foreach(light,D20Lights), code: {
       [H: rawName = json.get(light,"name")]
       [H: selectName = replace(rawName,"[^a-zA-Z0-9 ]","")]
       [H: lightNames = json.append(lightNames,rawName)]
       [H: lights = listAppend(lights,selectName)]
    }]
    [H: activeLight = getProperty("lightName")]
    [H: lightState = "0"+getProperty("lightState")]
    [H: select = json.indexOf(lightNames,activeLight)]
    [H: abort(input("lightIndex|"+lights+"|Select Light|LIST|SELECT="+select,"lightState|OFF,ON||RADIO|SPAN=TRUE ORIENT=H SELECT="+lightState))]
    [H: lightName = json.get(lightNames,lightIndex)]
    [H: setProperty("lightName",lightName)]
    [H: setProperty("lightState",lightState)]
    [H: setLight("D20",lightName,lightState)]
    
    !! 
If you don't want the PCs to use, just uncheck ownership for all players. You can change the image as you would any other token to represent your light source. If you don't want the PCs changing the light type you can add this line to the beginning of Set D20 Light:

Code: Select all

[H: abort(isGM())]
This will prevent non-GMs from running the macro.

keywords: amsave light

Re: [ADD ON] D20 Light

Posted: Fri Nov 16, 2012 2:11 pm
by Elorebaen
Thank you for sharing!

Re: [ADD ON] D20 Light

Posted: Sat Nov 17, 2012 5:40 am
by JML
Ditto :wink: