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

Rotating Token when arrow key is pressed.

So I am trying to run a Pokémon game for my players and would really like to be able to use classic sprites in the game for their characters. I'm hopping to emulate the tokens changing to face the direction their moving. I'm currently using the code posted by Wandering Magi (&nbsp; <a href="https://app.roll20.net/forum/post/2778056/script-token-face-change-based-on-rotation" rel="nofollow">https://app.roll20.net/forum/post/2778056/script-token-face-change-based-on-rotation</a> &nbsp;) Which changes the token face depending on the token direction, but needs to be manually rotated. I've tried combining this with other scripts that change the direction of the token when you press the arrow key but the codes don't seem to communicate with each other. Does anyone know of a Script that could do this or know how to add a 'rotate on key press' portion to the above script? My coding skills are very much lacking but I appreciate any help
1600980226
David M.
Pro
API Scripter
Don't think that is going to be possible, as the events exposed to the api don't include the necessary information. It just knows that a graphic object location has changed, and not the method in which it was moved. It also can't capture clicks or keyboard events.&nbsp;
I'm not sure if this is helpful, but I recently had to set up an easy way for a token to be rotated. Using the tokenmod script, I created macros for 90 degree turns in clockwise or counterclockwise directions. Then, I set those macros to appear in the Token Bar. My players could select their character token, then just click button in the token macro bar to rotate their token 90° in either direction. Tokenmod allows you to either set the token's direction to a certain rotation, or to rotate a certain amount relative to the token's current direction.&nbsp;
Scott P. said: I'm not sure if this is helpful, but I recently had to set up an easy way for a token to be rotated. Using the tokenmod script, I created macros for 90 degree turns in clockwise or counterclockwise directions. Then, I set those macros to appear in the Token Bar. My players could select their character token, then just click button in the token macro bar to rotate their token 90° in either direction. Tokenmod allows you to either set the token's direction to a certain rotation, or to rotate a certain amount relative to the token's current direction.&nbsp; Nice! Seems like a great place to use the "Emojis as Macro Labels" Stupid Trick : Clockwise:&nbsp; <a href="https://emojipedia.org/right-arrow-curving-left/" rel="nofollow">https://emojipedia.org/right-arrow-curving-left/</a> &nbsp;or&nbsp; <a href="https://emojipedia.org/right-arrow-curving-down/" rel="nofollow">https://emojipedia.org/right-arrow-curving-down/</a> !token-mod --set rotation|+90 Counterclockwise:&nbsp; <a href="https://emojipedia.org/left-arrow-curving-right/" rel="nofollow">https://emojipedia.org/left-arrow-curving-right/</a> &nbsp;or&nbsp; <a href="https://emojipedia.org/right-arrow-curving-up/" rel="nofollow">https://emojipedia.org/right-arrow-curving-up/</a> !token-mod --set rotation|-90
1601064805
Pat
Pro
API Scripter
The event passed to the on graphic change event includes the "old" position and the "new" position, so you *could* write a script that could evaluate the "direction" of that change and change facing accordingly. Would involve math.&nbsp;
1601291126
David M.
Pro
API Scripter
Good suggestions! For the latter, here is another older&nbsp; script that advertises rotating facing based on movement direction you might want to look into. Looks like there is a minimum distance moved filter that you would have to remove in order for it to work with arrow keys. As-is it ignores 5ft steps.