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

Triggering token changes based on proximity of other token(s)?

Greetings, Rollers (is that even a thing? No? Okay)! Sometime lurker, first time poster here. I've been playing in a couple of games on Roll20, and am in the process of setting one up and - as tends to happen - I'm putting far too much work into it. My players and I chipped in to get a Pro subscription, and I've been adding and tweaking all kinds of scripts. Before I try to write my own from scratch and going mad due to my nearly non-existent knowledge of Javascript, I figured I'd ask here: What would be the easiest and most efficient way to check if a token comes within a certain distance of another token, and Having Stuff Happen based on it? Primarily, I'd be looking to put together something that would let me change something like the token side of a multi-sided token when another token comes within a certain distance. Preferably, I would be able to set this up for multiple tokens with the option of changing individual parameters, as well as limiting the trigger to when the reacting token is "approached" by a token that fits certain criteria such as "has sight", "represents character", controlled by player, etc. Ideally, I'd set this up to have easily configurable settings for things like turning on a light, changing auras, moving And More™. Anyway, I tend to ramble, sorry... The basic question is up there in bold text; I'm reasonably confident that most of the things I want to do will be achievable, but I figured I'd ask for the basic functionality needed to actually check  for the triggers first, instead of trying from scratch or pillaging existing scripts until I find what I want. A somewhat silly example would be a two-sided token where the first side is a box, and when a player moves their token within 10' the token changes sides to a picture of a jack-in-the-box clown thing. If you made it to the end of this post, congratulations and thank you.
1571435461
GiGs
Pro
Sheet Author
API Scripter
The WorldMapDiscovery script in the one-click library does have something of this nature. You can read the script here:&nbsp; <a href="https://github.com/Roll20/roll20-api-scripts/tree/master/WorldMapDiscovery" rel="nofollow">https://github.com/Roll20/roll20-api-scripts/tree/master/WorldMapDiscovery</a> I dont know if its optimal, but it shows how you have to have a routine that runs when an object moves (the on(change) event).&nbsp; It sounds like your script will be pretty complex though, as you want to have a lot of different possible detections and events on detection. I think it'll be simpler to use tokenMod and similar scripts just to manually change things as need them.
Oh snap - I already have that script for my campaign, but hadn't gotten around to looking at it yet. I just took a look at the code, and it looks like a great starting point - iI didn't think about using aura radius, but with a GM only aura that makes all the sense. I was planning on using TokenMod and doing things manually like you suggest until I figure this out, but now I have some ideas on how to move forward. Thank you!