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