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)] !!
Code: Select all
[H: abort(isGM())]
keywords: amsave light