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

Layer-Switch Macro

1697882549

Edited 1697882728
Hello RollD20 experts, I need some direction for a macro or script that can switch pictures/tokens on the tabletop between layers without selecting. I have a Cyberpunk map and 3 different overlays (Like Metro Map, GPS Location Data, and some Traffic info) I wanna switch them on and off with one button (going from map layer to GM layer and vice versa) calling them directly. (Since you cannot select overlapping objects the same size anyway I know). Only thing I came up with so far would be a rollable table with every combination in it, but that would still require switching layers in is pretty large in file-/memorysize Thx in advance
1697900473
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Hi Dresden RPG! The Token-mod script can switch layers of selected objects. You can reference the object with its token id using the --ids parameter. To get a token id, select an object and run: @{selected|token_id} You can probably also reference it directly in the macro with @(Bob"token_id} but this is apt to break if there are two tokens named "Bob". The relevant syntax is in the Token-mod handout.
To add to what Keith mentioned about TokenMod, you can also use something like ScriptCards to whisper to you a little list with some buttons to switch layers with TokenMod. The below is a simple example with the overlays using a naming convention of "overlay-DESCRIPTION" to show all the overlays on the currently active page with the player ribbon. !scriptcards {{ --/|Requires: ScriptCards 2.1.7+, TokenMod --#title|Overlay Selector --#whisper|gm --#reentrant|GMOverlaySelector --~GraphicsFound|array;pagetokens;GraphicArr;[*C:playerpageid];graphic --?"[&GraphicsFound]" -eq "0"|NotFound --%graphicID|foreach;GraphicArr --?"[*[&graphicID]:t-name]" -ninc "overlay-"|% --+[*[&graphicID]:t-name]|[rbutton]Top::DisplayOverlay;[&graphicID][/rbutton] --%| -->Done| --:NotFound| --+ERROR|Did not find any matching graphics --:Done| --X| --:DisplayOverlay|OverlayID --#hidecard|1 --@token-mod|_ids [&reentryval] _order top }} In my example I had three maps on the map layer for various floors of a building and the whispered output looked like this: Then I can click on the buttons next to each item to move that overlay to the top.
1697912813

Edited 1697912891
Thank you very much. I'm already avoiding double names for tidiness reasons. Both answers are super helpful. Thanks guys.