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/Reset all Token Rotation API?

Hi All, I am GMing a Game with only front facing tokens and I would like that my player nor I cannot rotate any of the tokens. I have seen a number of various API scripts that do something similiar, but can someone point me to a script that will do this: Whenever you rotate any token, it just resets it to facing North. For Players and GM. Thanks, Elijah
1610510069

Edited 1610510504
Oosh
Sheet Author
API Scripter
There might already be something that does that.... but it's only a few lines. I think Aaron's TokenLock script either only locks movement, or locks both movement and rotation at once. on('ready', () => { on('change:token:rotation', (obj) => { getObj('graphic', obj.id).set('rotation', '0'); }) }) If you need to turn it on and off a lot, adding a toggle isn't too difficult. And if you have any tokens that face different directions, it could be modified to reset tokens to whatever rotation you have set when you toggle it on.
1610551250
The Aaron
Roll20 Production Team
API Scripter
Here's a slight refinement on what Oosh posted.  It only resets rotations on the Objects Layer (where Players can interact) and only for graphics that a player can interact with (where they control it or the character it represents).  The API doesn't get any notice of who performed an action (other than chat messages) so the best we can do is narrow it down by who could have done it.  If a player couldn't control it or access it, no need to reset the rotation.  This also resets it back to it's previous rotation, as Oosh suggested: on('ready',()=>{ const playerCanControl = (obj, playerid='any') => { const playerInControlledByList = (list, playerid) => list.includes('all') || list.includes(playerid) || ('any'===playerid && list.length); let players = obj.get('controlledby') .split(/,/) .filter(s=>s.length); if(playerInControlledByList(players,playerid)){ return true; } if('' !== obj.get('represents') ) { players = (getObj('character',obj.get('represents')) || {get: function(){return '';} } ) .get('controlledby').split(/,/) .filter(s=>s.length); return playerInControlledByList(players,playerid); } return false; }; on('change:graphic:rotation', (obj,prev) => { if('objects' === obj.get('layer') && playerCanControl(obj)){ obj.set('rotation',prev.rotation); } }); }); If you need to blanket reset everything, you can select everything on the page and use TokenMod: !token-mod --set rotation|0