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

Determine what layer the GM has selected

Hi All, I'm a long time programmer, a first time Mod writer and I'm new to Javascript. One of my issues as a GM is that I constantly think I'm on a certain layer when I'm actually on another.  I know the layer toolbar icon changes to represent the current layer, but I would like something a little more obvious. Is there a way to determine from within a script what the current layer is?  Can I be notified when the layer changes? I've looked at the API documentation for events, objects, etc, but I haven't been able to find anything. Once I can determine the current layer, I need to figure out how to display it for the GM.  I was thinking of using a handout that can be iconified and placed anywhere on the map, and then changing the name from within the script to indicate the current layer.  After some experimentation, I can change the name of the handout, but it doesn't update until I edit the handout.  Any ideas?  Can I draw something on the GM layer relative to the window (as opposed to the map) so that it is always in view? I know there are some browser extensions that can do this for me, but I would rather write a script myself. Cheers -- John
1682190059
timmaugh
Forum Champion
API Scripter
Hey John... welcome to mod writing! The layer a GM is on is not exposed (directly) to scripts, nor is there a game event that a script can listen for when a GM moves between layers... but you might be able to fake it... *and* with a pair of existing scripts. Here's the idea: Install Fetch and ZeroFrame . Then put this command in a Collections tab macro: !You are on the @(selected.layer[no selected token or no layer prop found]) layer.{&simple} To make it easiest to use, assign that macro to be in your button bar: Then, whenever you want to know what layer you're on, select a token in the VTT and run the above command. It might be nicer to have this as a token action button (so that you have to have a token selected before it becomes available), however...  since token actions only appear for the Object Layer, the command line has to be in a macro if you want to run it from an easily-accessible button. If, instead of using Fetch and ZeroFrame to do this you want to program your own solution, you just have to delve into the selected tokens of the message object. If you need help with that, post back. Script Suggestion Also, just as a side note, if you are going to write scripts, I might suggest the Inspector script as a way to quickly get a look at game components. For instance, if I run: !inspect --type player I'll get a list of players I can drill down on. And then by picking a player (in this case GM or not doesn't make a difference), I can see what is exposed to the script system: That might answer questions of "What is that property called?" or "Is that property available to me?" =D
1682194151

Edited 1682194257
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
If you use Stylus, this CSS snippet will recolor the toolbar icon background to help make it a little more obvious (let me know if you need more info): #floatingtoolbar li.objects{     color:black;     background-color:green; } #floatingtoolbar li.map{     color:black;     background-color:orange; } #editinglayer{     color:black;     background-color:blue; } #floatingtoolbar li.walls{     color:black;     background-color:yellow; } The GMLayer seems to be defined slightly differently, so I wasn't able to quickly find a way to re-color the icon for that style. But I made the rest black for more contrast. You can change any of the color definitions to meet your needs or for dark mode.
Thanks for these suggestions.  I'll probably pursue the Stylus suggestion since it is "always on." I will definitely look into the Inspector script. I appreciate the quick responses.  This seems to be a very helpful forum. -- John
1682221964
vÍnce
Pro
Sheet Author
keithcurtis said: If you use Stylus, this CSS snippet will recolor the toolbar icon background to help make it a little more obvious (let me know if you need more info): #floatingtoolbar li.objects{     color:black;     background-color:green; } #floatingtoolbar li.map{     color:black;     background-color:orange; } #editinglayer{     color:black;     background-color:blue; } #floatingtoolbar li.walls{     color:black;     background-color:yellow; } The GMLayer seems to be defined slightly differently, so I wasn't able to quickly find a way to re-color the icon for that style. But I made the rest black for more contrast. You can change any of the color definitions to meet your needs or for dark mode. Borrowed! Thanks Keith