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

Grid on/off hot key?

I understand there is no hotkey for turning the grid on and off, but I saw on a forum post a while ago a mention of an API that can do this.  Does anyone know what is called?
1682258119

Edited 1682258956
David M.
Pro
API Scripter
EDIT - I prefer the second version below: Haven't seen that mod before, but this should do it. Syntax: !togglegrid If a token is selected before running, then the grid on the selected token's page will be toggled. Otherwise, the grid on the current player ribbon page will be toggled. A message is whispered to chat based on this condition. const ToggleGrid = (() => { const scriptName = 'ToggleGrid'; const version = '0.1.0'; const checkInstall = () => { log(`-=> ${scriptName} v${version} <=-`); }; const ToggleGrid_handleInput = (msg) => { if(msg.type=="api" && msg.content.indexOf("!togglegrid") === 0 ) { let pageID, gmMessage; if (msg.selected !== undefined) { let selectedTok = getObj("graphic",msg.selected[0]._id); if (selectedTok) { pageID = selectedTok.get('_pageid'); gmMessage = 'Selected token page grid has been toggled' } } else { pageID = Campaign().get('playerpageid'); gmMessage = 'No token selected: Player ribbon page grid has been toggled' } let page = getObj('page', pageID); if (page) { let newGridStatus = !page.get('showgrid'); page.set('showgrid',newGridStatus); gmMessage = gmMessage + ` to ${newGridStatus}` sendChat(scriptName, `/w gm ${gmMessage}`) } } }; const registerEventHandlers = () => { on('chat:message', ToggleGrid_handleInput); }; on('ready', () => { checkInstall(); registerEventHandlers(); }); })();
1682258801

Edited 1682258843
David M.
Pro
API Scripter
Actually, this might be better and more user-friendly. Gets the GM's current page automatically and also prevents players from being able to toggle. Token selection not required and is ignored. Same trigger syntax: !togglegrid const ToggleGrid = (() => { const scriptName = 'ToggleGrid'; const version = '0.1.0'; const checkInstall = () => { log(`-=> ${scriptName} v${version} <=-`); }; const getPageForPlayer = (playerid) => { let player = getObj('player',playerid); if(playerIsGM(playerid)){ return player.get('lastpage') || Campaign().get('playerpageid'); } let psp = Campaign().get('playerspecificpages'); if(psp[playerid]){ return psp[playerid]; } return Campaign().get('playerpageid'); }; const ToggleGrid_handleInput = (msg) => { if('api'===msg.type && /^!togglegrid(\b\s|$)/i.test(msg.content) && playerIsGM(msg.playerid)){ let gmMessage; let pageID = getPageForPlayer(msg.playerid); let page = getObj('page',pageID); if (page) { let newGridStatus = !page.get('showgrid'); page.set('showgrid',newGridStatus); let gmMessage = `Page grid has been toggled to ${newGridStatus}` sendChat(scriptName, `/w gm ${gmMessage}`) } } }; const registerEventHandlers = () => { on('chat:message', ToggleGrid_handleInput); }; on('ready', () => { checkInstall(); registerEventHandlers(); }); })();