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 .
Advertisement Create a free account

Hooking into events before they happen


Edited 1620115281
Just starting out with the Roll20 API, and was looking for a way to hook into an event before the event actually executes. Specifically, I was looking for something like the change:graphic  event, but which would allow me to modify the change that was about to take place, sort of like a "before" hook.  The purpose, in my case, was for a script that simply centers a token within a grid cell. What I wanted was to set the correct x,y of the token as the token is dropped after having been moved, therefore always keeping it centered. What I found, though is that the best I can do so far is to use the change:graphic  event to update the position of the token after it's already been moved, which visually is shown as an extra movement following the initial movement, which doesn't look as good. Any ideas?
The Aaron
Forum Champion
API Scripter
The API event model is purely reactionary. There are only events for things that have already occurred.
That's what I concluded after reading the docs. Thanks for confirming!