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

Real time events with tokens (moving, rotation...)

Hi, It seems events such as: on("change:graphic:rotation", function(obj, prev) { }); Are triggered when the player drops the targetted item. While this is perfect for almost any situation, I'm currently working on puzzles where parts are moving in real time in relation to my players' action (like a Rubik's cube). To make things clear: I want to trigger an event when a player is currently moving or rotating an object, not when he stops doing so. I didn't find anything in the official wiki. Is there any workaround? Thank you.
1538863118

Edited 1538863271
The Aaron
Pro
API Scripter
This is not currently possible with the API.  The API is event driven, which means there would need to be an event like on('beginMove:token',...), which does not exist.  Furthermore, since the API is very much "action at a distance", it would be unlikely such an event would be satisfactory.  In all likelihood, the event would fire, but a response to it would be so far behind the action (because of network latency, timesharing of processing, time to process, database lookups, etc), that you would end up with slingshotting and other weird temporal results. The workaround I would suggest would be to break up the actions into events that are supported.  I can't speak to specifics for your case, but just imagining something where the rotation of a post (like a lever in Prince of Persia or a turnstile sort of thing) which causes changes to something like which doors are open in a passage, you might divide this into several api command which could be applied with buttons: !action grasp @{target|token_id} !action rotate-cw @{target|token_id} !action rotate-ccw @{target|token_id} !action release @{target|token_id} The player might then click various buttons from a menu that is whispered to them in chat: [Rotate CW] [Rotate CCW] [Release] to cause small changes on the tabletop and resultant effects to the doors or whatever is linked. Your starting action might be the only one that requires targeting, you could imagine a macro named "Grasp" that is shared with players: /em grasps the @{target|token_name}. !action grasp @{target|token_id} And the menu whispered to them wouldn't need to change or be resent: [Rotate CW](!action rotate-cw -JK1s4lk1234) [Rotate CCW](!action rotate-ccw -JK1s4lk1234) [Release](!action release -JK1s4lk1234) That would be my approach.
1538864665

Edited 1538864980
Thank you for your quick reply. I completely forgot API scripts are not run client side, so yeah roll20 can't do actual real-time. How funny, I was thinking about using the chat too if the API was not able to do real-time events. I originally avoided this idea because <a> elements (I didn't try with  Markdown , but this is the same right?) are triggered when the user stops clicking, meaning my players would need to spam buttons or I need to make "jumps" from one angle to another. I love the idea of being able to "Grasp" objects though, originally I thought about using buttons to switch between items.
1538867267
The Aaron
Pro
API Scripter
No problem.  I don't know if I made clear what I meant with the "the menu whispered to them wouldn't need to change or be resent" part.  If those rotate commands had no output, they could just keep clicking the button to apply a given effect multiple times.  Rather than grabbing and rotating 90º or more in one go, you might have each button press rotate by 15º, that would give you 6 clicks before the 90º turn finished, and ample opportunity to gradually show the effects of the changes.  The other benefit of this technique is that you don't need to give a player control of the object being affected.  You could use its aura to show things about it.  Perhaps a yellow aura means you can grasp it, and a green aura means you have grasped it.  The sky's the limit and such. =D
1538868074

Edited 1538868103
Well, I'm not an expert with roll20, but I think I got it.  -JK1s4lk1234  is the object ID in plain text, so you only need to send it once with each object, right? Auras can work pretty well, as long as objects are not overlapping. I'll try with tints color. 
1538868252
The Aaron
Pro
API Scripter
Right, the generated menu can hard code the token_id which is being manipulated, as passed by the !grasp command. Tint's are another great option.  You could even use a Rollable Table Token and change the face that's shown.