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

How to use a Macro/API to extinguish all lights on the lighting layer of a page

I have a map with many lights on the lighting layer and, as part of the effects when the big gribbly appears I want to extinguish all the lights on the page as near simultaneously as possible.  I still need dynamic lighting to be enabled as the players will start to try to light torches etc. I hoping something like scriptcards can do the job, assuming it can somehow  enumerate all the light sources on the lighting layer? Any/all guidance greatly appreciated.
1750439241

Edited 1750439285
I do this using a macro with Tokenmod commands. I created an NPC character sheet called Ambient_Light and linked it to a token. I place that token in the areas that I want illuminated, on the lighting layer. I then created macros that look for all tokens with that name and either turn light emitting off, or turn bright or low light on, set it's range and in the case of low light its brightness.
Thanks Rick, that's a possible, although I'll have to replace all my lights - I'll go that route if no other method is suggested.
There's probably a way to select all tokens on a layer and turn light emitting off for all of them, but that might be more than you want. (I'm on my mobile right now so I'm not really able to easily look at all the Tokenmod options)
1750446587
timmaugh
Forum Champion
API Scripter
You shouldn't have to replace your lights.  To execute the effect you're looking for, you'd need to have TokenMod and the MetascriptToolbox installed, then run something like: !forselected token-mod --set emits_bright|false emits_low|false {&select *, +type=token, +layer=walls} They should all turn off almost instantaneously... there might be a slight stagger since the light sources are being iterated over, but it will be very immediate. That's Really It; That's the Answer What, You Want More? Fair enough... the above solution leads to the question of: how do you get those torches to turn back on? You can change the "false"s in the command, above, to "true"s, and that will restore those properties (of course, this is a bit genericized... if you don't need "bright" light, for instance, you might want to omit that one to begin with; I'll leave it to you to match your requirements exactly). Also, I think there's a "flip" command in TokenMod that could replace the true/false... but that would flip the lights individually (I think)... so if any of them were out of phase (ie, they were already off), you might inadvertently turn them on! However... You might want to be able to turn subsets of light on again (without having to go to the lighting layer and fiddle with the torches individually). In this case, you might want them to be individually named. But that can also be automated. Let's just assume that you will name the torches with a name that is "Torch" followed by a unique number (i.e., "Torch1", "Torch2", etc.). If they are a part of a sub-group that you might want to control individually (like the torches making the Dungeon Greeting Hall such a warm and welcoming place), then you can append the room name to the end of the name and add another number for the index of the light IN THIS ROOM (i.e., "Torch8_DungeonGreetingHall1", "Torch9_DungeonGreetingHall2", etc.). All of this would take about 2 minutes per map, with the speed of your typing being the longest wait factor in the process. =D Here's how you'd do it: Run this command to name ALL of the torches on a given map: !forselected token-mod --set name|Torch{&i+1} {&select *, +type=token, +layer=walls} That render names like "Torch1", "Torch2", etc. Now pick your sub-groups of lights (only you can determine which of them you know you might, during a game, want to manipulate). For our purposes, let's say you've selected the torches in the Dungeon Greeting Hall. Now you'd run this command: !forselected(^) token-mod --set name|"@^(selected.token_name)_?{Enter Group Name}{&i+1}" ...and answer the query prompt with "DungeonGreetingHall" -- or whatever name you want to give this group.  All of the torches in that room would now have the "_DungeonGreetingHall1" formation with numbers that count up from there. Select the next group of tokens you want to be able to manipulate individually and repeat (providing the unique name). Now you can prepare command lines that give you control over the groups. For instance, to turn on/off all lights, you could use the commands above. To turn off the Dungeon Greeting Hall torches, specifically, you could use: !forselected token-mod --set emits_bright|false emits_low|false {&select *DungeonGreetingHall*, +type=token, +layer=walls} ...or change the "false"s to be "true"s to turn them on. Then you could put all of those commands on a chat menu to give you a "Light Control" dashboard you can quickly use fiddle with rooms. Or, if you just wanted a single command, to control any/all combinations, you could run this: !forselected token-mod --set emits_bright|?{Turn lights...|ON,true|OFF,false} emits_low|false {&select *?{In what room?||Dungeon Greeting Hall,DungeonGreetingHall|Dungeon Massage Therapy Zone,DungeonMassageTherapyZone}*, +type=token, +layer=walls} To control ALL lighting tokens, leave the second query at the blank option (the option that is presented when the query comes up). Otherwise, pick among the rooms you have set up (here listing 2... DungeonGreetingHall and DungeonMassageTherapyZone). Any time you want to turn any of the lights for a map on/off you can run that command, select the direction (on/off), then the zone.
@timmaugh absolutely awesome mate!! thanks, the slight delay works out really well, it's like a wave of darkness sweeping over the map and the auto naming bit saved me a huge amount of work. Now to add a suitable 'Hammer House of Horror' sound effect/background ambience and I'm done.