The Aaron said: That's very clever and fun! Great way to demo the script. =D I did notice that dragging the token to the left exit from the start screen causes the transition, but using the keyboard arrow keys to do it does not. Likely there is some very small math error that causes the position not to match the target. For exactly that reason, I rewrote the matching function in the original a while back. Here's what I used: var findContains = function(obj,layer){
"use strict";
var cx = obj.get('left'),
cy = obj.get('top');
if(obj) {
layer = layer || 'gmlayer';
return _.chain(findObjs({
_pageid: obj.get('pageid'),
_type: "graphic",
layer: layer
}))
.reduce(function(m,o){
var l=o.get('left'),
t=o.get('top'),
w=o.get('width'),
h=o.get('height'),
ol=l-(w/2),
or=l+(w/2),
ot=t-(h/2),
ob=t+(h/2);
if( ol <= cx && cx <= or
&& ot <= cy && cy <= ob
){
m.push(o);
}
return m;
},[])
.value();
}
return [];
};
And the first part of where I called it: on("change:graphic", function(obj) {
"use strict";
if (obj.get("name").indexOf("Teleport") !== -1) {
return; //Do not teleport teleport pads!!
}
if (Teleporter.AUTOTELEPORTER === false) {
return; //Exit if auto Teleport is disabled
}
/* To use this system, you need to name two Teleportation locations the same
* with only an A and B distinction. For instance Teleport01A and Teleport01B
* will be linked together. When a token gets on one location, it will be
* Teleported to the other automatically */
//Finds the current teleportation location
var CurrName = "";
var location = findContains(obj,'gmlayer');
if (location.length === 0) {
return;
}
Cheers! Thanks for the tip! This is like the third time I've done anything in Javascript, so I'm not surprised there's issues. I'll update the gist when I get back from work.