Quick update:
I identified the problem keithcurtis was having with gmlayer player tokens interfering with teleports. Turns out I was essentially grabbing the first overlapping token in the gmlayer, seeing if it had a coresponding destination teleporter, then returning! Apparently it works so long as the teleporters were added to the page before the tokens being teleported.
I have a fix but looping through the overlapping tokens required a little restructuring of the code. I took the opportunity to add better logging and comments, plus a couple of other minor features which arose from the restructuring:
1. The collisions check detects if any part of the token and source teleporter overlap. Previously tokens would only teleport if their center overlapped with the source teleporter.
2. The improved collision detection now means that teleporters larger than 1x1 will function like you'd expect, so long as the source and destination are the same size.
3. "But won't I be teleported if I move my token within a teleporter larger than 1x1?" you ask. Not any more! Now the script checks the token's 'lastmove' value and only triggers a teleport if the token's previous position did not overlap the teleporter.
4. As part of the fix for the bug keithcurtis reported I now loop through all the overlapping gmlayer tokens with a name and check to see if there is a valid destination on a page with a corresponding token.
5. Changed handling of characters controlled by more than one player to be more consistent (previously it basically picked the first thing in the listi and ran with it). If all the players control a token and it is teleported to another page the players will be united onto the destination page. If more than one player controls a token then all controlling players will be moved to the destination page.
I still need to test these changes and may need to make some adjustments to the collision check for maps which use hexes, but I'll leave you with some interesting potential applications of these changes:
* Connecting 2 square wide hallways with matched 2x1 teleporters
* Creating single teleporter which splits the party by teleporting different players to different maps (Use same destination name on multiple pages and place player tokens only on the maps to which you want the teleporter to take them)
* Allow tokens significantly larger than teleporter to use it reliably (ex. 3x3 token and 1x1 teleporters)
* Elevator encounters where players can move around inside of elevator without being teleported back.
* Reliable and accurate teleportation if grid is disable