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 .
×

Is there any API to limit character control of tokens to only arrow key movement?

Hello! New to pro here and been looking for an API to limit player control of tokens to only arrow key movements. Is this a thing already? An API available somewhere?
1646607754
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
There is not. I don't think that the API can distinguish between the two types of move either. The on:change  event doesn't know how the x-y position was changed. One could theoretically create a script that would register any position change and then move the token back to where it would have been had it only moved one grid square, but you'd have to account for differing grid sizes and patterns, and whether there is a grid urned on at all. The token would still move, it would just snap back the the nearest cell adjacent of the origin cell. Look at this another way, what are you trying to accomplish?
1646610685

Edited 1646610731
keithcurtis said: There is not. I don't think that the API can distinguish between the two types of move either. The on:change  event doesn't know how the x-y position was changed. One could theoretically create a script that would register any position change and then move the token back to where it would have been had it only moved one grid square, but you'd have to account for differing grid sizes and patterns, and whether there is a grid urned on at all. The token would still move, it would just snap back the the nearest cell adjacent of the origin cell. Look at this another way, what are you trying to accomplish? I was looking for a solution concerning traps and the one API that triggers based on token placement. I was trying to build a battlefield situation and figure a way to allow LoS and limit their movement so they do not just blow themselves up. If there is no easy way I will probably just tell them beforehand and pray they understand. Mite also add the API that locks tokens based on turn order. I am new to a lot of this though so there mite definitely be a better solution. Thank you for your response.
1646610917
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Yeah, it would probably be a lot simpler just to tell them and hope they can comply with moving that way. Most players want to have fun, so...
1646853631

Edited 1646853652
Andreas J.
Forum Champion
Sheet Author
Translator
Interesting enough, a Locked token can be moved which TokeMod commands. Which leads to:
1646855479
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I would very much hope this would be the case. It would definitely restrict players to moving one square at a time, but I don't know if API-generted movement will do what the OP wants: trigger It's a Trap.
1646985685
The Aaron
Roll20 Production Team
API Scripter
I was thinking It's a Trap would interpolate movement and trigger if a token would have moved over it, pulling them back to the point of impact.