[Script] It's A Trap! v2.3

1461306405

Edited 1508171476
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
It's A Trap! v3.6 This is a script for setting up automated traps. The script allows traps to be interpreted with system-specific rules through Trap Theme scripts written for various character sheets. General documentation and update logs can be found in its  README on GitHub. Demo: Now available from One-Click: It's A Trap D&D 3.5 Edition theme D&D 5E generic theme Gamma World 7E theme Pathfinder generic theme Roleplaying is Magic 4E theme World of Darkness (classic) theme Available from Roll20 API repository: D&D 4E Requested Trap Themes Shadowrun (Need rules) Known issues: traps activating from dropped tokens (could not reproduce) traps with attack AND save (don't do this!) Known conflicts: Blood and Honor Future versions roadmap More generic system trap themes (Specify character attribute names through One-Click options to provide easy support for custom sheets or games that only use attributes in place of sheets) Issue multiple API commands upon trigger. Active search/perception listening PF theme touch attacks Option to remove trap after it trigger Blast area polygons Trigger radius Having Trouble? If you're having problems setting up traps with this script, please post your problem to this thread and I will try to address it soon. When you do so, please be sure to also provide the JSON for the trap giving you trouble and let me know what trap theme you are using. This would greatly help me to diagnose what the issue is.
1461319679
Ziechael
Pro
Sheet Author
API Scripter
Oh boy oh boy oh boy, I've been using a 'hacked' version for months which allowed inline rolls in GM notes for custom trap outputs (thanks The Aaron!) but to have it officially supported is immense... and now for my full list of ideal additions ;) have it so that the bars can be used to set some trap values (maybe DC, save type and jukebox sound to play?) For example bar1value of 15, bar 2 value of Reflex and bar3value of springloaded would tell the script to output as part of the text [[bar2value]] Save DC [[bar1value]] and trigger the jukebox to play the sound called 'springloaded' :) Some way in which 'passive' searching could be enabled to detect traps, maybe even with a way to have active searching increase that chance of success (maybe auras and collision, although that would raise the issue of it passing through walls unless you could find a way to restrict that via your coding magic??) This is the code snippet Aaron put together for me for my general sound support which allows me to have general akbar announce "it's a trap!" for hilarity when a trap is triggered at present... you prob don't need it but i'm all about sharing :) var PlaySound = function(trackname, time) { var track = findObjs({type: 'jukeboxtrack', title: trackname})[0]; track.set('playing',false); track.set('softstop',false); if(track) { track.set('playing',true); } else { log("No track found"); } };
1461321692
I'm thrilled to see an update to this great script! Thank you, Stephen L. !
1461324172
Ravenknight
KS Backer
Thank you! Just in time too, my players are facing an ancient Vampire Castle and the traps inside this weekend. :)
1461334664

Edited 1461334774
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
Ziechael said: Oh boy oh boy oh boy, I've been using a 'hacked' version for months which allowed inline rolls in GM notes for custom trap outputs (thanks The Aaron!) but to have it officially supported is immense... and now for my full list of ideal additions ;) have it so that the bars can be used to set some trap values (maybe DC, save type and jukebox sound to play?) For example bar1value of 15, bar 2 value of Reflex and bar3value of springloaded would tell the script to output as part of the text [[bar2value]] Save DC [[bar1value]] and trigger the jukebox to play the sound called 'springloaded' :) Those are some great suggestions. This script has always been intended to be system-agnostic, so no direct support is planned for automating D&D style trap mechanics. Some way in which 'passive' searching could be enabled to detect traps, maybe even with a way to have active searching increase that chance of success (maybe auras and collision, although that would raise the issue of it passing through walls unless you could find a way to restrict that via your coding magic??) Again, how active/passive searching is handled is very much system-specific. However, I could do some fancy mathemagics with my PathMath utility script create a function to get all the traps that a character would be able to search for within some search radius, with support for walls blocking the way. This could be tied into some sort of D&D 5 or [Insert your system here] trap searching script.  A couple enhancements I have planned for the near future are support for API chat commands in the trap messages, and being able to specify trap parameters in the GM Notes as JSON. The JSON enhancement would tie in well with the trap interpreters enhancement since it would allow users to specify parameters in addition to whatever is in the Bar 1,2,3 values. Properties in the JSON would include support for trap message templates, names of sounds to play, and special FX definitions (once that rolls out onto Production).
1461536836

Edited 1461547164
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
Update v2.2 now available! See the updated original post. Please let me know if you guys want to see TrapThemes to support specific character sheets.
1461573477
Ziechael
Pro
Sheet Author
API Scripter
Awesome, I love how this is growing! Would love to see support for 3.5e DnD for those of us who love pointlessly complex mathematics and contradictory/vague rules :)
1461698634
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
Ziechael said: Awesome, I love how this is growing! Would love to see support for 3.5e DnD for those of us who love pointlessly complex mathematics and contradictory/vague rules :) I've got D&D 3.5 on the roadmap for sheets to implement TrapThemes for. Which D&D 3.5 character sheet is your game using?
1461710711
Ziechael
Pro
Sheet Author
API Scripter
A custom one derived from Diana's awesome community one. My customisations revolve around the inventory so shouldn't have any impact on any TrapThemes implementation :)
1461868212

Edited 1461868226
Would it be possible to get the JSON script examples for the trap's settings? I have the 5eOGL going, but I cannot seem to get it to say anything other than "Invalid blah blah blah" when I put the JSON code in for the additional effects.
1461869743
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
Christopher (Obi) said: Would it be possible to get the JSON script examples for the trap's settings? I have the 5eOGL going, but I cannot seem to get it to say anything other than "Invalid blah blah blah" when I put the JSON code in for the additional effects. Done. The OP has been edited to include a couple examples.
Stephen L. said: Christopher (Obi) said: Would it be possible to get the JSON script examples for the trap's settings? I have the 5eOGL going, but I cannot seem to get it to say anything other than "Invalid blah blah blah" when I put the JSON code in for the additional effects. Done. The OP has been edited to include a couple examples. Bless you sir. Love this script.
I seem to be getting an "Infinite loop crash" but I can't determine the circumstances causing it....
1461882147

Edited 1461885177
Okay, so what's happening: I have a player who, for some reason, can't see traps...then, sometimes, he causes a crash (infinite loop). I can't seem to figure out why. Edit: It seems to be if the character has a First and Last name when the token is first edited and saved, for some odd reason...I don't know if that's it, but the two characters having trouble have first and last names.
1461886446
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
I've been testing with characters that have anywhere from 1-3 words in their names with no problem. Have you made sure that ItsATrap is the cause of it by disabling all other scripts except ItsATrap and its dependencies?
Stephen L. said: I've been testing with characters that have anywhere from 1-3 words in their names with no problem. Have you made sure that ItsATrap is the cause of it by disabling all other scripts except ItsATrap and its dependencies? I'll do that today and get back to you.
1461912214

Edited 1461919303
 Just to list whats running now in case it raises any flags already: Torch 5eOGL companion and sheet Mystars Calendar And the It's a trap stuff. I'll get in and test it later. Seems to just be bugging for the two characters.
Okay, so I disabled everything but Its a Trap and its dependencies. Still no luck with the bugged character (even with new tokens and changing the name). I made them new character cards, and those new ones work just fine, though, but that doesn't help find the cause of the bug, eh? Just to confirm what runs with Its a Trap: Vector Math Token Collsions Matrix Math Path Math and the Its a Trap 5thE OGL Theme
1461936623
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
yes, those are all the scripts needed to run ItsATrap with 5E-OGL. I have so far been unable to replicate your issue. The only way for me to get an idea of what could be wrong would be to mess around in your game with the API scripts and the two characters.
I'll see what I can do to allow that. Thanks, sorry I couldn't be more clear about the circumstances.
1461956257

Edited 1461956723
Well, I've figured out what's causing it...just not how its causing it (I'm not a scipter) If I check the Proficiency in Wisdom, no matter the character, that character sheet will no longer work with the script...at all. I've unchecked it and it still does not spot. I've tested it 5 times so far and it replicates each time. EDIT: I've got a fix for it....uncheck the checkbox, then just use the options to mod it up to the right number, then go into your character's abilities (the roll20 ones) and delete the entry for perception_prof and then it'll work. I hope this helps to find the real culprit!
1461959783
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
Ok, I might have an idea of where it might be goofing up in the 5E-OGL theme. I'll see about getting that patched up soon.
Stephen L. said: Ok, I might have an idea of where it might be goofing up in the 5E-OGL theme. I'll see about getting that patched up soon. Rock on!
1462126028

Edited 1462126468
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
Got those fixes in for the 5E-OGL theme. You can get the new version here until the pull request is processed:  https://github.com/Cazra/roll20-api-scripts/tree/TrapTheme5EOGL/ItsATrap_theme_5E_OGL On an unrelated note: Due to issues with compatibility between attributes in the character sheet and API systems, I am discontinuing the theme for the 5E Community sheet. I might pick it back up if better support is added to the API for getting calculated attributes from a character sheet.
1462127675
Fantastic Script!!! I am trying to work on a 4e hack to work with 4e character sheet and power cards but it gives an error when using the character.get('id') both on the passive perception and the trigger: "ERROR: Did not specify an attribute name when referencing attribute using @{-Jy4Dslhq6dZkU3ebs3k}" The lines of code are: var TrapMsg = {}; TrapMsg.who = character.get('name') ; TrapMsg.content = "!power --charid|@{" + character.get('id') + "} --emote|" + character.get('name') + " has found a trap --format|trap --name|IT'S A TRAP!!"; PowerCard.Process(TrapMsg); i am sure it is somethign simple i am missing!
1462128227
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
Characters do not have an "id" property. They do have an "_id" property though. ;) Hope that solves your issue.
1462129114

Edited 1462130965
Hi Stephen, thanks for the reply its finding the character id -Jy4Dslhq6dZkU3ebs3k in this case, and using it to create the avatar etc, but it looks lie it is also looking for attributes that i cant see why. it may be more of a powercards issue than this? Edit: - ignore all that, was me being an idiot!! @{ } was not needed around character.get('id') Thank you for your help still though.
1462132326

Edited 1462132699
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
Update: A trap theme for Diana P.'s D&D 3.5 Edition character sheet is now available.The theme name is "DnD-3.5".  https://github.com/Cazra/roll20-api-scripts/tree/T... Please note that at this time, AC for this theme has limited support. This is due to how calculated attributes are resolved in the API vs on character sheets. If this API bug is fixed, the AC feature of the script should begin working again automatically though.
1462133554
Ziechael
Pro
Sheet Author
API Scripter
Sweeeeet, will have to find time to test this soon :) Thanks for the great work Stephen!
1462218906
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
Update: v2.3 is now available. This version expands the trap JSON to allow special FX. This property is currently supported by the 'default' and 'test' themes, but I'll make it available soon in the other official themes.
1462485148
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
Update: Token Collisions 1.3 is now unofficially available, with support for rectangular collisions (including rotated rectangles).  This will allow collisions with rectangular traps. It's not merged yet, but if you guys want to play with it, you can replace whichever version of Token Collisions you have with the one on my 1.3 branch here:  https://github.com/Cazra/roll20-api-scripts/tree/T... To set a trap as rectangular using Token Collisions 1.3, just set the trap's Aura1 to be a square.
1462729146

Edited 1462729283
Hi there, I've just installed this script and have manually added the 5th Edition Shaped script to run alongside. Added in the theme to the script all right, and tested it using the two examples you give in the documentation, and it seems to work great except for one thing - any characters that have armour on, it adds 10 to their AC. If the character has no armour in-putted on their sheet at all it calculates correctly. Any ideas on what I could be doing wrong? Edit: I also seem to be getting errors in the log stating "ERROR: You tried to use the repeating section row at index 28 for repeating_skill, but there doesn't seem to be a row at that index." The index number basically errors out for anything past 18. Although it doesn't seem to cause a problem in the actual running of the script.
1462750633

Edited 1462768802
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
Xiavn said: Hi there, I've just installed this script and have manually added the 5th Edition Shaped script to run alongside. Added in the theme to the script all right, and tested it using the two examples you give in the documentation, and it seems to work great except for one thing - any characters that have armour on, it adds 10 to their AC. If the character has no armour in-putted on their sheet at all it calculates correctly. Any ideas on what I could be doing wrong? I must have made a mistake while making the theme for the sheet. Anytime I tried to give a character armor, their AC would become just the bonus from their armor, and not have the usual base 10 to their AC. So it seemed weird that a character in fullplate had only AC 8 whereas an unarmored character with a Dex modifier of 10 had AC 10... On the other hand, I've never touched any of the 5E character sheets before creating the trap themes, so I'm not familiar with some of their peculiarities.  This is a result of me derping because there was a lot of pressure for the 5E trap theme to be made, and me still being sort of a noob about 5E. >_< When I created the sheet, I was thinking armor gave a bonus to AC like in DnD 3.5, instead of it being just the character's base AC. I'll get that fix in so it'll be correct next merge-day. Edit: I also seem to be getting errors in the log stating "ERROR: You tried to use the repeating section row at index 28 for repeating_skill, but there doesn't seem to be a row at that index." The index number basically errors out for anything past 18. Although it doesn't seem to cause a problem in the actual running of the script. It does that when it trying to find the passive perception for a character. Because there is currently no way from the API to tell how many rows are in a repeating section, it tries to find the perception skill within the first 30 (just in case someone decides they REALLY need to have a bunch of additional homebrew skills) skills in the repeating skills list. When it goes beyond the actual number of items in the list, it starts displaying those error message, but it doesn't appear to actually throw an Error about it, so it's not like I can just catch it in a try-block. I'm still looking for a work-around on this. Sorry that there are still some bugs to work out for the theme. :( Edit: I discovered Aaron's technique for getting repeated section attributes using filterObjs and getAttrByName. So now I've refactored the theme so that it should have better performance and not have those index errors. That will hopefully be available to everyone (along with the armored AC fix) on the next merge day.
That seems to be working great now! Both the AC and the the errors are all working correctly now. However, I have another query regarding the spot DC. Does it actually check the spotDC against Perception or Wisdom? I ask because it seems to be working correctly on a character without proficiency in perception (i.e, their wisdom modifier = their perception), but not for someone who has proficiency in perception (i.e. their perception is two points higher than their wisdom). Sorry! I feel like all I'm doing is picking holes, but it's honestly a superb script. I just probably spend way too long prepping stuff down into way too precise details for my game (my players seem to think so at least).
1462801257
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
I actually haven't put these changes in my master branch yet, but proficient passive perception is working fine for me in my coding sandbox with the new fixes. If you'd like to try out the fixes early, here's the branch for it here: https://github.com/Cazra/roll20-api-scripts/tree/TrapThemeFXUpdates/ItsATrap_theme_5E_Shaped
1462802166
The Aaron
Pro
API Scripter
Stephen L. said: Edit: I discovered Aaron's technique for getting repeated section attributes using filterObjs and getAttrByName. So now I've refactored the theme so that it should have better performance and not have those index errors. That will hopefully be available to everyone (along with the armored AC fix) on the next merge day. Cool!  I didn't even realize I had a technique for that. =D  Happy to (passively) help!
1462803129

Edited 1462803396
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
Yes, while searching for ways to extract repeated items from character sheets, I stumbled across your response here:  https://app.roll20.net/forum/post/2107785/slug%7D
1462803753
The Aaron
Pro
API Scripter
Ah, interesting.  That code won't work in the post-reorderable-repeating-sections era, but I assume you adjusted the regex to account for that.  Something like: var char = /* got from somewhere */; var conditions = filterObjs( function(o){ return o.get('type') === 'attribute' && o.get('characterid') === char.id && /repeating_moves_ [^_]+ _condition/.test(o.get('name')) ; }); getAttrByName() is an annoying beast.  I have lots of code that expects it to return a formula instead of a value.  I'll have to do some testing...
1462805389
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
Yeah, I modified the regex to get the row IDs instead of the row indexes. It would be nice to have a version of getAttrByName that returns the resolved value of a calculated field instead of the formula. For now, I've just been expanding out the formulas and processing the end result with an inline roll in sendChat.
1462806542
The Aaron
Pro
API Scripter
Oh, I think the confusion is that getAttrByName() resolves autocalc fields that aren't backed by actual attribute objects, but will return formulas if they are there.
Stephen L. said: I actually haven't put these changes in my master branch yet, but proficient passive perception is working fine for me in my coding sandbox with the new fixes. If you'd like to try out the fixes early, here's the branch for it here:  https://github.com/Cazra/roll20-api-scripts/tree/TrapThemeFXUpdates/ItsATrap_theme_5E_Shaped Yeah that's the one I tested I with earlier I believe, the AC was working perfectly. I've also just retested, and yeah the proficiency in perception is working (I tested with another character), apparently the issue I had earlier is the original character I tested with (who had the proficiency bonus) just doesn't spot traps whatsoever, however low they are. I shall have to investigate further.
Okay, after a bit of testing (after figuring out how to log to the api console), I've figured out that this section of the passive perception check:     var skills = filterObjs(function(o) {       return o.get('type') === 'attribute' &&         o.get('characterid') === character.get('_id') &&         /repeating_skill_-?([a-zA-Z]|\d)+_name/.test(o.get('name'));     }); Is basically returning an empty array for my one character that isn't working. Whereas for everyone else it's obviously returning an array of what looks like all the passive skills? Any ideas what might be up with her character? I tried duplicating the sheet, changing the name, etc, and it still doesn't work. Tried regenerating the skills. I assume the next step is going to be to just remake the character entirely.
1462817673
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
If that character has been around for a while, it's possible that their skills are still using row indexes instead of row IDs. Try replacing  /repeating_skill_-?([a-zA-Z]|\d)+_name/ with /repeating_skill_(-|\$)([a-zA-Z]|\d)+_name/
Stephen L. said: If that character has been around for a while, it's possible that their skills are still using row indexes instead of row IDs. Try replacing  /repeating_skill_-?([a-zA-Z]|\d)+_name/ with /repeating_skill_(-|\$)([a-zA-Z]|\d)+_name/ No luck with this fix I'm afraid - the character was made at roughly the same time as others, so I think it has the correct row ID's. However after a bit more delving, and playing around I have pinned it down - the issue seems to be that this particular character has a hyphen in the id field for the skills (-KDi-B4dTSzpBqHOoX2K to be exact for perception). I also noticed that this characters character id had a double underscore in it, which seemed to be unique amongst all my characters; not sure if this is why it generated the skills with a hyphen. Anyway this regex seems to be working at the moment:  /repeating_skill_(-|\$)([a-zA-Z-]|\d)+_name/ But I'm not sure if there would be a more elegant solution. As much as I love looking at code and playing with regex, I will admit I'm very much a learner.
1462836904

Edited 1462837338
The Aaron
Pro
API Scripter
I'd suggest: /repeating_skill_(\$\d+|-[a-zA-Z0-9\-]+)_name/ The function that generates row ids can generate a dash inside the id.   Here is a regex101 workarea for it:  https://regex101.com/r/vH3zT2/1 Edit: I should read more deeply, I see you ran into the same thing. =D The code that generates the ids is this: var generateUUID = (function() {     "use strict";     var a = 0, b = [];     return function() {         var c = (new Date()).getTime() + 0, d = c === a;         a = c;         for (var e = new Array(8), f = 7; 0 <= f; f--) {             e[f] = "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".charAt(c % 64);             c = Math.floor(c / 64);         }         c = e.join("");         if (d) {             for (f = 11; 0 <= f && 63 === b[f]; f--) {                 b[f] = 0;             }             b[f]++;         } else {             for (f = 0; 12 > f; f++) {                 b[f] = Math.floor(64 * Math.random());             }         }         for (f = 0; 12 > f; f++){             c += "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".charAt(b[f]);         }         return c;     }; }()), generateRowID = function () {     "use strict";     return generateUUID().replace(/_/g, "Z"); }; It's basically base64 encoding a block of data which is highly unlikely to be repeated in order to generate a unique ID.  _ is a valid character in that id, so technically, a character ID of -______________ would be completely valid (all IDs from this function begin with a - because of what I can only assume is an off by one error).  In the case of RowIDs, the _ is necessarily replaced by another character (Z) as _ is something of a delimiter in attribute names.  (Subbing in a Z increases the likelihood of a collision (1.5625% overlap in keyspace), though not by nearly as much as lowercasing the whole thing (40.625% overlap in keyspace).)
1462887317

Edited 1462887737
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
Ah yes, regex101 is my favorite site for testing out regular expressions. It also saves me a lot of time converting the README files for my scripts into description strings for the script.json files. From the example IDs on the wiki, I was under the impression that row indexes start with '$' and rowIDs start with '-', followed by an alpha-numeric string. Where did you find the code for generating row IDs? I'm not finding anything about it on the wiki.
1462888762
The Aaron
Pro
API Scripter
I dug it out of the site. =D
1462890230
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
The regex should be fixed to work with those characters now.  https://github.com/Cazra/roll20-api-scripts/blob/T... The regular expression I went with is: repeating_skill_(-([0-9a-zA-Z\-_](?!_storage))+?|\$\d+?)_name
1463014746
Scott C.
Pro
API Scripter
Hey Stephen, I was wondering, what are the limits on what can be done with the trap themes? is it limited to attacks/AC/Damage? Thanks, Scott
1463016330
Stephen L.
Pro
Marketplace Creator
Sheet Author
API Scripter
There aren't any limits to what can be done with traps in your own trap themes. ItsATrap provides some functions for playing a sound defined in the trap's JSON, spawning FX defined in the trap's JSON, and circling traps that a character passively spots, which can be called in your activateTrap and passiveSearch implementations. Other than that, you can code your trap theme to do whatever you want with the API. The trap JSON object always includes the ID of the token that triggered the trap and the ID of the trap token so you can do things specifically with that trap and victim. 
1463044392
Scott C.
Pro
API Scripter
Stephen L. said: Update: Token Collisions 1.3 is now unofficially available, with support for rectangular collisions (including rotated rectangles).  This will allow collisions with rectangular traps. It's not merged yet, but if you guys want to play with it, you can replace whichever version of Token Collisions you have with the one on my 1.3 branch here:  https://github.com/Cazra/roll20-api-scripts/tree/T... To set a trap as rectangular using Token Collisions 1.3, just set the trap's Aura1 to be a square. Hi Stephen, I'm getting an error using the new Token Collisions 1.3.  TypeError: other.get is not a function TypeError: other.get is not a function at apiscript.js:175:24 at /home/node/d20-api-server/node_modules/underscore/underscore.js:380:19 at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:172:24) at Function._.sortBy (/home/node/d20-api-server/node_modules/underscore/underscore.js:376:22) at _.(anonymous function) [as sortBy] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1496:34) at _getCollisionsInWaypoint (apiscript.js:167:11) at apiscript.js:141:20 at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:172:24) at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1496:34) at Object.getCollisions (apiscript.js:140:12) I think it's from this codes segment (lines 55-87): function _getCollisionsInWaypoint(token, others, waypoint) {        var startPt = waypoint[0];        var endPt = waypoint[1];        var numCollisions = 0;        return _.chain(others)          // Get the list of tokens that actually collide, sorted by the distance          // from the starting point at which they occur.          .sortBy(function(other) {            var dist;             if(token.get('aura1_square'))               if(other.get('aura1_square'))                 dist = _testRectsCollision(token, other, waypoint);               else                 dist = _testRectCircleCollision(token, other, waypoint);            else               if(other.get('aura1_square'))                 dist = _testCircleRectCollision(token, other, waypoint);               else                 dist = _testCirclesCollision(token, other, waypoint);            if(dist !== undefined)              numCollisions++;            return dist;          })          // Other tokens with undefined collision distance will be sorted to the high          // end of the list. So, we'll just drop them.          .first(numCollisions)          .value();      } But other than that I'm stymied. I'm trying to call Token Collisions with the following code:    getDestinationCollisions = function(token) {         var pageId,         destinations,         collisions,         lastCollision;         pageId = token.get('_pageid');         destinations = getDestinations(pageId);         collisions = TokenCollisions.getCollisions(token, destinations);         lastCollision = _.last(collisions);    },          getDestinations = function(pageId){         return findObjs({             pageid: pageId,             type: 'graphic',             layer: /*'map' ||*/ 'gmlayer',             statusmarkers: 'aura'         })[0];     }, If I comment out the "collisions =" and "lastCollisions =" lines and log all the variables I get: "pageId" "-Jo6Dd7nZqSelv3fMvdG" "token" {"_id":"-Jp2cpJ5LRb6rewwjAJg","_pageid":"-Jo6Dd7nZqSelv3fMvdG","left":3395,"top":1085,"width":70,"height":70,"rotation":0,"layer":"objects","isdrawing":false,"flipv":false,"fliph":false,"imgsrc":"https://s3.amazonaws.com/files.d20.io/images/7039467/f7qYLQ3M1plP_Fg1wFQkcg/thumb.png?1420690169","name":"","gmnotes":"","controlledby":"","bar1_value":"","bar1_max":"","bar1_link":"","bar2_value":"","bar2_max":"","bar2_link":"","bar3_value":"","bar3_max":"","bar3_link":"","represents":"","aura1_radius":"","aura1_color":"#FFFF99","aura1_square":false,"aura2_radius":"","aura2_color":"#59E594","aura2_square":false,"tint_color":"transparent","statusmarkers":"","showname":false,"showplayers_name":false,"showplayers_bar1":false,"showplayers_bar2":false,"showplayers_bar3":false,"showplayers_aura1":false,"showplayers_aura2":false,"playersedit_name":true,"playersedit_bar1":true,"playersedit_bar2":true,"playersedit_bar3":true,"playersedit_aura1":true,"playersedit_aura2":true,"light_radius":"","light_dimradius":"","light_otherplayers":false,"light_hassight":false,"light_angle":"","light_losangle":"","light_multiplier":1,"sides":"","currentSide":0,"lastmove":"3395,1155","_type":"graphic","_subtype":"token","_cardid":""} "destinations" {"_id":"-KHXcUKIYyHbJGZIf8do","_pageid":"-Jo6Dd7nZqSelv3fMvdG","left":3395,"top":1050,"width":210,"height":140,"rotation":0,"layer":"gmlayer","isdrawing":false,"flipv":false,"fliph":false,"imgsrc":"https://s3.amazonaws.com/files.d20.io/images/17909715/MSbM_vNTea-EnPc74F_DFA/thumb.png?1459987051","name":"Scrapwall","gmnotes":"","controlledby":"","bar1_value":"","bar1_max":"","bar1_link":"","bar2_value":"","bar2_max":"","bar2_link":"","bar3_value":"","bar3_max":"","bar3_link":"","represents":"","aura1_radius":"","aura1_color":"#FFFF99","aura1_square":true,"aura2_radius":"","aura2_color":"#59E594","aura2_square":false,"tint_color":"transparent","statusmarkers":"aura","showname":false,"showplayers_name":false,"showplayers_bar1":false,"showplayers_bar2":false,"showplayers_bar3":false,"showplayers_aura1":false,"showplayers_aura2":false,"playersedit_name":true,"playersedit_bar1":true,"playersedit_bar2":true,"playersedit_bar3":true,"playersedit_aura1":true,"playersedit_aura2":true,"light_radius":"","light_dimradius":"","light_otherplayers":false,"light_hassight":false,"light_angle":"","light_losangle":"","light_multiplier":1,"sides":"","currentSide":0,"lastmove":"3325,1085","_type":"graphic","_subtype":"token","_cardid":""} So I'm reasonably sure I'm passing valid objects to TokenCollisions. Any ideas? Thanks, Scott