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: <a href="https://github.com/Cazra/roll20-api-scripts/tree/T" rel="nofollow">https://github.com/Cazra/roll20-api-scripts/tree/T</a>... 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":"<a href="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" rel="nofollow">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</a>":""}
"destinations"
{"_id":"-KHXcUKIYyHbJGZIf8do","_pageid":"-Jo6Dd7nZqSelv3fMvdG","left":3395,"top":1050,"width":210,"height":140,"rotation":0,"layer":"gmlayer","isdrawing":false,"flipv":false,"fliph":false,"imgsrc":"<a href="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" rel="nofollow">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</a>":""}
So I'm reasonably sure I'm passing valid objects to TokenCollisions. Any ideas? Thanks, Scott