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

Lock a Token

Hello, is it possible to lock a token ? i want it to be unmovable  Thanks have a nice day
1618399154
David M.
Pro
API Scripter
Yep! The TokenLock script is what you want. It's available for one-click install.
OK thanks a lot  other question : does it exist a script to lock the token's size, i want the size not to be changed with a mouse click or scroll on a token ?
1618404152
The Aaron
Roll20 Production Team
API Scripter
Just the size, or other properties like location and rotation?  You can try MapLock from the 1-click installs. Tell us about your use case though, there might be something better. 
OK i want to lock the size of the token                   id=       -MYFyWo6veyliao6pCuV what have i to write ? thanks
1618415326
The Aaron
Roll20 Production Team
API Scripter
Give this a try with the script below installed and one or more tokens selected: !toggle-size-lock Script: /* globals TokenMod */ on('ready',()=>{ const scriptName = 'LockTokenSize'; const version = '0.1.0'; const schemaVersion = 0.1; const lastUpdate = 1618415215; const checkInstall = () => { log(`-=> ${scriptName} v${version} <=- [${lastUpdate}]`); if ( !state.hasOwnProperty(scriptName) || state[scriptName].version !== schemaVersion ) { log(` > Updating Schema to v${schemaVersion} <`); switch (state[scriptName] && state[scriptName].version) { case 0.1: /* break; // intentional dropthrough */ /* falls through */ case "UpdateSchemaVersion": state[scriptName].version = schemaVersion; break; default: state[scriptName] = { version: schemaVersion, sizeLockedTokens: [] }; break; } } }; checkInstall(); on('chat:message',msg=>{ if('api'===msg.type && /^!toggle-size-lock(\b\s|$)/i.test(msg.content) && playerIsGM(msg.playerid)){ let who = (getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname'); let msgs = []; (msg.selected || []) .map(o=>getObj('graphic',o._id)) .filter(g=>undefined !== g) .forEach(t=>{ if(state[scriptName].sizeLockedTokens.includes(t.id)){ state[scriptName].sizeLockedTokens = state[scriptName].sizeLockedTokens.filter(id => t.id !== id); msgs.push(`<li>Unlocked Token <b>${t.get('name')}</b> (<code style="white-space:nowrap">${t.id}</code>)</li>`); } else { state[scriptName].sizeLockedTokens.push(t.id); msgs.push(`<li>Locked Token <b>${t.get('name')}</b> (<code style="white-space:nowrap">${t.id}</code>)</li>`); } }) ; if(msgs.length){ sendChat('', `/w "${who}" <div style="font-size: .8em; background-color: #cccccc; border:1px solid #999; padding: .3em;"><ul>${msgs.join('')}</ul></div>`); } } }); const changeGraphic = (obj,prev) => { if(state[scriptName].sizeLockedTokens.includes(obj.id)){ if(obj.get('width') !== prev.width || obj.get('height') !== prev.height){ obj.set({ width: prev.width, height: prev.height, top: prev.top, left: prev.left }); } } }; on('change:graphic',changeGraphic); if('undefined' !== typeof TokenMod && TokenMod.ObserveTokenChange){ TokenMod.ObserveTokenChange(changeGraphic); } });
OK thanks a lot have a nice day
OK it works but only with other players and not when you're the GM i want it to be lock-sized even for the GM ! is it possible ? thanks
1619015244
The Aaron
Roll20 Production Team
API Scripter
Are you locking the token first? Select the token and run: !toggle-size-lock You should get a message telling you the name and ids of the tokens that it locked or unlocked. I just tried this as GM and it prevented my resizing as well.
yes i select the token , run  !toggle-size-lock      and the message appears but the token is still resizable (screenshot) i tried to change the token's layer to another layer but it doesn't work
1619022438
The Aaron
Roll20 Production Team
API Scripter
What other scripts do you have installed?
i send you a screenshot the script named "bloquerlataille" is the script to lock the tokens 
1619029627
The Aaron
Roll20 Production Team
API Scripter
I don't think it would make a difference, but try disabling MapLock and TokenLock.  It's working fine for locking the GM for me currently.   You are resizing with the mouse, right?  Not with a script?
ok i disabled maplock and tokenlock but it's the same problem yes i'm resizing with the mouse
1619035468
The Aaron
Roll20 Production Team
API Scripter
Hmm... If you want to PM me an invite and GM me, I can see if I can figure out why it's not working.
OK what is your email ?
1619096129
The Aaron
Roll20 Production Team
API Scripter
Joined.  You can click someone's name and send them a Private Message.  You'll want to remove that join link so you don't get random people or bots joining your game.
ok thanks , i play tonight from 9 PM (french time) until late in the night so can you look tomorrow for example ? thanks
1619211987
The Aaron
Roll20 Production Team
API Scripter
Very strange, but it seems to be working now.  I left one token which I have locked the size on on the first page with a label next to it.  You should be able to just select and lock the ones you want to prevent resizing on now.
Hi, it isn't locked i can resize it with the mouse  ! strange !!! i think something is "on" in the settings so i can resize it even if it's locked ?! you did it  with a GM role so it's like me, i don't understand !!!
1619224462
The Aaron
Roll20 Production Team
API Scripter
You resized the one I left with a label? Or one of the other ones?  If it's one of the other ones you'll need to select it and toggle the locking on for it.  
Hi, i resized the one you locked with the label and tried to lock another one but it doesn't work !
if you manage to lock it , something is different between you and me in the settings of roll20 ? no? i'm GM too like you !!!
1619277557
The Aaron
Roll20 Production Team
API Scripter
Hmm.  Can you PM me a join link again?  I dropped out of the game since it was working...  Do you not get any chat messages from it at all?  Could it be that what you're typing for the command is using some other unicode characters?