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

[Script] Teleport - from scratch teleport token.

1605462661

Edited 1605463191
Pat
Pro
API Scripter
Craig Steinhoff said: Can this Teleport to a new map or is it only internal map sections? I can work on to-another-map teleport, it's not too difficult in terms of some of the mechanics - it's just that I wanted this to be easy out-of-the-box, and page-to-page requires more prep work from the user. Either the token has to have image resources uploaded, or already be on the GM layer of the target page... One thing I neglected was multiple-character select-teleport (where the GM grabs the whole party or a few of the party) and teleports them to another destination.
1605463036

Edited 1605463163
Pat
Pro
API Scripter
Jay R. said: I really like the use cases you mentioned in the updated docs, Pat. Simulating someone getting washed downstream or monsters coming out of a portal are two instances I hadn't thought of in relation to this script. Thank you for all this work! Thanks - you can also use it to place a bunch of special effects you want to trigger "remotely" (without having to get out the tool) by placing portal pads with SFX and no links - you can then use the teleporter list like an SFX control panel. Say, if you're playing a WWI setup and you want to stage artillery bombardments without having to think about getting the SFX tool out and then putting it away... Or to draw player attention - the "Ping" Is system-level, so it drags everyone - if you need to point out a bunch of things in series, you can do it as well with a few portal pads and clicking the "ping" button. Say you're doing a setup of a guide using a map, with a bunch of waypoints - say in a heist "...And then you get into the doorway *here* (press ping button on that teleport pad at that waypoint)"... get that Ocean's Eleven feel...  You could make a quiz, where the room has text, and there is one portal linked to two others with multi-portal:select - each labeled as an answer - and one teleports them to another question and the other to the "sorry, you failed" room instead.  You could make a coded elevator, where one of the floors has a keycode and won't show up unless you have a token - and then emulate "hacking" the elevator by removing the selector true-false, meaning all rooms are open, but they're random...  There are a lot of potential unexplored possibilities when the linking is done this way. 
Pat said: Thanks - you can also use it to place a bunch of special effects you want to trigger "remotely" (without having to get out the tool) by placing portal pads with SFX and no links - you can then use the teleporter list like an SFX control panel. Say, if you're playing a WWI setup and you want to stage artillery bombardments without having to think about getting the SFX tool out and then putting it away... Ooh, this has nasty trap potential, I like it! Question: if a player is using waypoints to move their token, will the pad still trigger if it's in the waypoint path?
1605468923
Pat
Pro
API Scripter
Jay R. said: Pat said: Thanks - you can also use it to place a bunch of special effects you want to trigger "remotely" (without having to get out the tool) by placing portal pads with SFX and no links - you can then use the teleporter list like an SFX control panel. Say, if you're playing a WWI setup and you want to stage artillery bombardments without having to think about getting the SFX tool out and then putting it away... Ooh, this has nasty trap potential, I like it! Question: if a player is using waypoints to move their token, will the pad still trigger if it's in the waypoint path? Right now, the pad only takes into account the current location, on drop. I'm not sure I could have it interrupt somebody who was moving through an area until they finished their move in any case... that final move triggers the "onchange:token" event. Checking all waypoints would require multiple iterations of the script to check for teleport, which runs right now on ending their move - it checks the current page teleport pads for intersection with the token. If it has to iterate over the full list of waypoints... it's a little math, it could be done - but it might seem counter-intuitive for a player to move past a location and then be dropped in another. Probably have to set a flag for "activates on waypoints" 
Cool, thanks for the explanation. It's not a huge deal for me. I might just have my players move square by square.
1605469575

Edited 1605470459
Pat
Pro
API Scripter
Working on the next iteration - attempting to link cross-page. First getting the directed teleport to work - so if you select one or many characters, it can teleport cross-page to the destination you choose. I'll have to write a lot of checking for existing tokens, creating token attempts if available, checking for tokens that use the marketplace... once that's done (direct teleport) the auto-teleport should just be about linking and using existing functions to check for teleport and then invoking the manual teleport functions, that will be by then already defined, to auto-teleport a player to another page. Only consideration: if they appear back on the page later, not through teleport, their token will likely be in the gmlayer - and I don't have an auto-fix idea to force that... and I'm not sure I should.  Edit: and now I'm thinking for this to work, I'll have to track a global state setting called "teleport.limbo" - an object indexed by pageid - that tracks all player-tokens that were whisked to the gmlayer due to teleport, and auto-manifest them back in the world if the page changes and the controlling player is newly on the page they originally teleported *from*. Edit Again: to make this user friendly, I'll be putting error messages in the chat, and providing a setting for the gm to set a preference to attempt creating a token or not. If the preference is set to "not" the gm will get a warning if they try and teleport a token and there is not a supporting token on the destination page (gm layer or token layer). If the preference is set to "attempt to create" the gm will get a warning if I can figure out if an image src is from the marketplace, and abandon the attempt. I feel like these warning conditions should stop auto-teleport - and maybe notify the player and the gm in that case.  Edit Edit Edit: one final obstacle is the lack of API to move the GM - the players and player ribbons can be moved, but no API call exists to move the GM - so the players will all move, and maybe the SFX will fire and the pings will fire... but the GM will be left behind regardless. 
1605473758

Edited 1605484905
Pat
Pro
API Scripter
Well, good news it technically already works to link portals across pages.  ...bad news is there is a lot of work to do to get it to execute on the actual target page and not on the player ribbon page where it wants to execute... gonna have to research how to get something to execute in the proper context.  Edit: Silly me - it's all about _ids, so as long as I match up IDs (tokens in different pages linked to the same character sheet and controlled by the same player not the GM) I should be able to do it - just creating will be a bit of a task, copying all of the token features from one to another - enumeration or quick? Not sure...  SFX may be another matter - wait, they also have a page id parameter! I'll have to get the context instead of just stuffing in Campaign().playerpageid every time. 
1605514277

Edited 1605514592
Pat
Pro
API Scripter
Success. I am tired, it is not in any way finessed yet (need to work on the interface and a quick way to put player tokens to and from the gm layer, and splice off the player from the player ribbon, and re-merge them if they teleport back to the main player ribbon) - but it works in that you can set a teleport pad to link to a pad on another page, the logic recognizes this mid-teleport for either direct or auto teleport, and tries to "fix" it by finding the target token matching token on the new page. It doesn't split off a new player specific ribbon yet - it moves the whole ribbon to the destination. It is not where it attempts to create a token if one is not provided yet It is not well-automated to put tokens to and from the GM layer yet But it's wired up and works. I don't have it out in my git yet - soon. Just a bit more clean-up, and then we might have a functional cross-page teleport pad manager. Future State:  Split-party teleports when auto or manual teleporting Re-merge when teleporting to player ribbon page Better management of duplicate tokens across pages (if using that method and not token creation - still have to manage token creation) Really, it's the unintentional teleportation clones that are the problem - do I start answering the age-old Ship of Theseus problem by ... offing the clones?  pad crowding - try not to put tokens over one-another Along with above: multi-select teleport (teleport multiple selected tokens at once - useful for players, or GMs teleporting in bad guys from "upstairs" Edit: Plus, I may have (MAY HAVE) successfully submitted the first version (1.0, just within-page teleportation) to the repository for one-click, so hopefully more people will get a chance to use it soon. (crosses fingers) - I expect to have this version ready for beta testing in about a week, and if all goes right, maybe up in the one-click repository by December? Maybe? Would people use this? 
I would use the hell out of a teleport script between pages, Pat! Can't wait to see how this develops. I'll be sure to give you my feedback.
1605534707
Pat
Pro
API Scripter
Jay R. said: I would use the hell out of a teleport script between pages, Pat! Can't wait to see how this develops. I'll be sure to give you my feedback. If you want to try what I've got - it doesn't move the GM so you have to chase the ribbon to see where it goes - but it does auto-teleport across pages right now and brings the (entire) player ribbon with (so everybody gets dragged) - I'd recommend trying it on a new campaign with just a few pages at first and a player who can give you good feedback.  I'll upload it to a git gist, and post the link here.  You'll have to disable or not use the current teleport.js Cross-page Teleport.js
1605537472
Pat
Pro
API Scripter
Ah one thing I didn't consider - if the teleport occurs for one character, then later characters also move from that page by other means, then there's one gm layer character and the rest of the characters just standing around immobile... I'm wondering if I need to set up something where if a player is not on a page, all of their controlled tokens are hidden or moved to limbo during the same teleport? Probably should be a toggle-clean-up destination maybe? 
1605578401
Pat
Pro
API Scripter
Got a note - single-page teleport has been merged into one-click, I think. So it should be available tomorrow in one-click, where I'll see if it worked or did not. Good luck with the single-page version, all! Hopefully the cross-page version will be ready by November 30 for distribution Dec 1. 
I've also got a dungeon coming up in my campaign where multi-page teleports would be awesome. However, it would be individual characters being teleported at a time, not the whole party. If they could get split out individually, that would be perfect: I don't mind manually merging them into the player ribbon later if that makes it easier.
1605608278
Pat
Pro
API Scripter
Terin said: I've also got a dungeon coming up in my campaign where multi-page teleports would be awesome. However, it would be individual characters being teleported at a time, not the whole party. If they could get split out individually, that would be perfect: I don't mind manually merging them into the player ribbon later if that makes it easier. Okay - this version may have some bugs, I can't guarantee it will work - the limbo functions don't work yet (there is no simple way to set a player token so that it can be quickly searched and moved to the GM layer for the destination teleport pad for example - you just create all your players tokens on the target page and move them to the gmlayer...the script will tell you if it can't find a target token, and this version doesn't try and create a token yet.) - but this *supposedly* splits off the player specific page... at least it does in the data... so you'll have to test this with a player you trust in-game: teleport.js with player-ribbon-splitting (experimental)
There is a Teleport script already, it is frustrating as it works sometimes and doesn't work sometimes. In theory it has page to page teleports. Don't rush it, get it right, we can wait.
1605639940
Pat
Pro
API Scripter
Teleport is up right now in one-click. I will now submerge again until I have more news on teleport 1.1: the cross page version. It may have other enhancements as well, so I'll publish a change log here when I'm ready to test 1.1
I've used Final Frog's Mapteleporter script and have not had any major problems. It definitely teleports page to page and does not move the player ribbon. But, it does require a fair amount of setup which is why I'm interested in Pat's script. The time spent in setup, however, saved me a ton of effort in-game to move the player's tokens (I had a castle of 11 levels - each level on a separate page - with multiple stairwells leading to different parts of levels). The biggest issue was when the player was moved to the destination page - the other tokens they had control over were orphaned and they had no way to control them so I just moved them myself onto the teleporter pad. Honestly, if I had to make sure there are player tokens on gmlayers of all the maps with teleporter pads, that's not an issue. I'll be giving both scripts a try.
Hello Pat, it is a verry great job and you did't stop a minute. I am trying the  script and I have an error acurs. When I tried as MD, no problem, but when I Join as player, my token is send to the md layer so I can't see the token. I haven't try with a player. Here is the error: "In checkTokenMarkerMatch" TypeError: Cannot read property 'get' of undefined TypeError: Cannot read property 'get' of undefined     at teleportPing (apiscript.js:661:35)     at Timeout._onTimeout (apiscript.js:648:25)     at listOnTimeout (internal/timers.js:549:17)     at processTimers (internal/timers.js:492:7) I hope it can help to improve the script. Thank you for the big job.
1605662071

Edited 1605664577
Pat
Pro
API Scripter
Nicolas G. said: Hello Pat, it is a verry great job and you did't stop a minute. I am trying the  script and I have an error acurs. When I tried as MD, no problem, but when I Join as player, my token is send to the md layer so I can't see the token. I haven't try with a player. Here is the error: "In checkTokenMarkerMatch" TypeError: Cannot read property 'get' of undefined TypeError: Cannot read property 'get' of undefined     at teleportPing (apiscript.js:661:35)     at Timeout._onTimeout (apiscript.js:648:25)     at listOnTimeout (internal/timers.js:549:17)     at processTimers (internal/timers.js:492:7) I hope it can help to improve the script. Thank you for the big job. The indicators would seem to be trying to ping a token that ...has no player? Normally there is a catch for that in the default player (gm) so I'm not sure why it's failing for you.  Edit: Was this in the one-click, or the git gist version?  Edit edit: When you join as player, you're still the DM so it won't move your split-off player ribbon. That's why it'd be in the GM layer on the transmitting page. I'm trying to think of how the "get player" would fail catastrophically, when normally it tries to get the player, and if it doesn't it grabs the DM - so how could it get left with no applicable character, yet have moved the player to the new page and found a token there? 
1605699464

Edited 1605700332
Pat
Pro
API Scripter
Doug E. said: I've used Final Frog's Mapteleporter script and have not had any major problems. It definitely teleports page to page and does not move the player ribbon. But, it does require a fair amount of setup which is why I'm interested in Pat's script. The time spent in setup, however, saved me a ton of effort in-game to move the player's tokens (I had a castle of 11 levels - each level on a separate page - with multiple stairwells leading to different parts of levels). The biggest issue was when the player was moved to the destination page - the other tokens they had control over were orphaned and they had no way to control them so I just moved them myself onto the teleporter pad. Honestly, if I had to make sure there are player tokens on gmlayers of all the maps with teleporter pads, that's not an issue. I'll be giving both scripts a try. This was something I was considering - should a teleport have a toggle to pull all associated active player tokens in the same cross-page teleport?  With in-page teleport, it's not necessary - any other tokens they control they can still control, and there's no splitting of action. I'm planning multi-player teleport, so a GM should be able to grab multiple tokens and trigger a teleport.  So the outlier case is: do we grab all the extra tokens that are associated with the player: IF they are auto-teleporting AND it's to another page which requires moving the individual player ribbon AND they have other tokens on the originating page that are controlled by the moving player? It would have to check for all of the associated tokens too and initiate teleports for all of them, any of which could fail on their own if they don't have associated tokens.  The GM could initiate this instead by selecting the associated tokens and "manually" teleporting them with the teleport buttons.  Should the default be no or yes? 
Pat said: The indicators would seem to be trying to ping a token that ...has no player? Normally there is a catch for that in the default player (gm) so I'm not sure why it's failing for you.  Edit: Was this in the one-click, or the git gist version?  Edit edit: When you join as player, you're still the DM so it won't move your split-off player ribbon. That's why it'd be in the GM layer on the transmitting page. I'm trying to think of how the "get player" would fail catastrophically, when normally it tries to get the player, and if it doesn't it grabs the DM - so how could it get left with no applicable character, yet have moved the player to the new page and found a token there?  Thank you for the explanation, I have tried with a player and there is no problem. Except that the player (and me too when I tried) loose the selection when is token is teleport. It is not a big issue, but it break a little bit the immersion. Pat said: So the outlier case is: do we grab all the extra tokens that are associated with the player: IF they are auto-teleporting AND it's to another page which requires moving the individual player ribbon AND they have other tokens on the originating page that are controlled by the moving player? It would have to check for all of the associated tokens too and initiate teleports for all of them, any of which could fail on their own if they don't have associated tokens.  The GM could initiate this instead by selecting the associated tokens and "manually" teleporting them with the teleport buttons.  Should the default be no or yes?  My opinion, not a very useful one, is the default should be teleporting all the token from the player. Thanks again for this amazing work.
1605730967
Pat
Pro
API Scripter
Nicolas G. said: Thank you for the explanation, I have tried with a player and there is no problem. Except that the player (and me too when I tried) loose the selection when is token is teleport. It is not a big issue, but it break a little bit the immersion. This is part of moving the token to the GM layer. If the token isn't moved to the GM layer, the tabletop animates it along the ground between the two teleportation points, and isn't... very convincing as a teleport effect. Nicolas G.  said: My opinion, not a very useful one, is the default should be teleporting all the token from the player. Thanks again for this amazing work.  I'll likely make it a toggle, just in case a character is meant to be isolated from their companions instead of automatically taking along everyone. 
1605732656
Pat
Pro
API Scripter
I think I figured out the error that you got,  Nicolas G. : I was not checking for a comma-delimited list for player controllers. I'll be doing that now - a multi-character controlled token may not teleport well page to page, as even teleporting in-page will cause problems as the ping won't know which player to select. I may have to put in multiple checks, as I can't see a "success" condition for a token that has multiple controllers, especially cross-page. 
1605785600

Edited 1605793471
Pat
Pro
API Scripter
Okay, new version: Cross-Page Teleport with Add Links T his one reconciles a few issues: Trying to teleport or cross-page teleport a token with an associated character sheet with multiple controlling players no longer crashes the ping or cross-page teleport Added the "add link" button to the global teleport pad list, a non-destructive way to add additional links to a link-list. The way it was there was no way to add teleport pads from multiple different pages to the same originating teleport pad - it was locked to one-to-one, or one-to-many within the same target page. With this version, you can link multiple target teleport pads on different target pages and set the originating link to "select" and get a list of possible targets.  Made sure that link pad and add link buttons keep context and return to the list type they were activated from.  Global list for player-controlled tokens in the gm player per page. No images or associated indicators yet - and limbo may not work as a token management paradigm. Still tinkering. There still appear to be some issues with Campaign().get('playerspecificpages') and its modification which are preventing validation of re-merging player ribbons with the main player ribbon. I'll have to recruit a few players to help me test. Need to check for object layer graphic move only - realized that when placing an image on the map layer today and had a terrain feature auto-teleport. So that's going to go in next... I guess I could turn it off (deactivate the portal) but it really shouldn't be teleporting map items . Fixed. Edit: Added GM context to create and view pads...  Now when creating pads or viewing non-global pad lists, they keep the context of the gm editing the page , not the campaign player ribbon.  Activating SFX only will now activate in the pad context always , instead of active player ribbon only. 
1605800158

Edited 1605823321
Pat
Pro
API Scripter
Pushed the update with cross-page teleport to one-click. It fixes outstanding bugs and corrects issues with context of teleport pads when creating new teleport pads, though I'm not 100% on the long-term cross-page teleport managing player ribbons. If anyone can test the gist (located here ), or can help by checking the one-click should it go ahead and go in on Monday. 
1605823789
Pat
Pro
API Scripter
Update Added "Add Link" button to global links, to be able to add to the current list instead of replace it, essential for cross-page teleportation.:  The "Pad List" with details is now in context of where the GM is instead of the player ribbon, which means "create teleport pad" will always pull up the list in the same context, meaning it will no longer appear to not work and cause frustration: 
1605863422

Edited 1605865960
Hello Pat, I was trying to make the upgrade working... and I didn't. In fact, the one-click version seems to not exist anymore ( Error downloading scripts (probably no scripts exist for campaign.) ) but I think it is because it's link to the 1.0 and the 1.1 is not activate before monday (I am right ?). The two last gist link made something that it not make my script crashed. I can have all menu very correctly, and some alert (when I tried to make teleport pad without token selected for example). But, still without player, I am not able to teleport a token. Nothing move when I move a token (that I own or not) to the teleport pad (place on the GM layer). I Still can move a token on a teleport pad with the "Teleport Token" button from the "Teleport Pad List". I have retry old version to be sure and previous version still work. And the fact that we can create token on the active page and not on the ribbon page is awesome. What can I do to make more useful test ? edit: I am trying a lot of thing, and, when I select a Token on an active page with the ribbon on it and I click on the "Teleport Token" button from the "Teleport Pad List" from an other page, the script crashed. Edit 2 : You haven't modified the help page, I think it is the line 126: output += '<p>Each pad has an individual menu for invoking teleport for a selected token, and for pinging a pad if you cannot locate it on the page.</p>' ; Right now, the Teleport Pad display is <b> fixed to the player ribbon </b> meaning that the list of teleport pads only displays those' +
1605869595
Pat
Pro
API Scripter
Nicolas G. said: Hello Pat, I was trying to make the upgrade working... and I didn't. In fact, the one-click version seems to not exist anymore ( Error downloading scripts (probably no scripts exist for campaign.) ) but I think it is because it's link to the 1.0 and the 1.1 is not activate before monday (I am right ?). The two last gist link made something that it not make my script crashed. I can have all menu very correctly, and some alert (when I tried to make teleport pad without token selected for example). But, still without player, I am not able to teleport a token. Nothing move when I move a token (that I own or not) to the teleport pad (place on the GM layer). I Still can move a token on a teleport pad with the "Teleport Token" button from the "Teleport Pad List". I have retry old version to be sure and previous version still work. And the fact that we can create token on the active page and not on the ribbon page is awesome. What can I do to make more useful test ? edit: I am trying a lot of thing, and, when I select a Token on an active page with the ribbon on it and I click on the "Teleport Token" button from the "Teleport Pad List" from an other page, the script crashed. Edit 2 : You haven't modified the help page, I think it is the line 126: output += '<p>Each pad has an individual menu for invoking teleport for a selected token, and for pinging a pad if you cannot locate it on the page.</p>' ; Right now, the Teleport Pad display is <b> fixed to the player ribbon </b> meaning that the list of teleport pads only displays those' + Thank you for testing. When I threw together the last change, I only checked the negative case of not teleporting objects on the gm or map layers, and did not positively test the "objects" layer tokens, which I had mistakenly set to "object" instead, which means nobody was getting teleported automatically. I'll be pulling my update for Monday and re-submitting it this weekend.  New gist updated here: Cross-Page Teleport
1605990399

Edited 1605990448
Pat
Pro
API Scripter
Update Multiple corrections and refinements, improved stability, new gist and new push to one-click for Tuesday, November 24.  Added help handout with more extensive information, corresponds with both one-click information and with README.md, and linked to handout from initial startup: 
1605992083
Andreas J.
Forum Champion
Sheet Author
Translator
Very nice.
I had tried the last version. I had to re-create some pad and some map configured for previous version but after that, all seems to work perfectly. I still not tried with a real player but all teleport work perfectly. The last touch would be the ribbon management. For now, the ribbon doesn't follow the teleported character and even if I separate myself from the ribbon. I will try with a player, it can be different.
1606048684

Edited 1606049300
Pat
Pro
API Scripter
Nicolas G. said: I had tried the last version. I had to re-create some pad and some map configured for previous version but after that, all seems to work perfectly. I still not tried with a real player but all teleport work perfectly. The last touch would be the ribbon management. For now, the ribbon doesn't follow the teleported character and even if I separate myself from the ribbon. I will try with a player, it can be different. Currently, the GM, even if in "player" mode, won't get moved (even if the entire player ribbon is moved - there's no way to move the GM: there is no way to do so in the API), and right now the entire player ribbon won't get moved (there is not a case for all players moving at once) - so that's part of what I need to test and refine - when does the entire player ribbon get moved? A majority of players? All players? When the last player moves to the new "majority" ribbon?  Edit: in short, future development needs to include:  Teleporting character collision when more than one character teleports (destination pad is "occupied") - the WC update.  Managing the player ribbon - maybe a toggle to do so, as some GMs may not want the algorithm I'd use to do so. GM selecting and teleporting more than one character at once with "manual" teleport, see point 1.  An appropriate delay to cross-page teleport ping. Is the ping too soon for a player that is moved, so that the ping doesn't move the player view due to delays in moving to another page? 
Great job, the future development is for perfecting the script, and for me it is already a wonderful one. Thanks again.
I finally got around to test the script. First, functionally it is fantastic! I love the menus, FX, message, etc. Could use a little more documentation in the handout - examples would help. What I have issue with, is the UI in setting up the links being counter-intuitive. For example, if I want to have Telepad 1 (origin) teleport to Telepad 2 (destination) , I have to select Telepad 2 and in the pad list, click on the link for Telepad 1. It is more intuitive with both teleport tokens selected and click on the origin pad and it will set up the link from origin to destination but that is not necessarily practical and it is impossible for cross-page selection. A more intuitive workflow would be to select the origin token and click on the link button in the list for the destination, adding links with the Add Link button for more than one destination. Also, some way to create two-way teleporters with one button would be awesome.  Personally, I wouldn't worry about the player ribbon, the GM can reconcile the players and ribbon quite easily, but that's me. I will definitely be making use of this script at some point. Thanks
Excellent work, I'm so excited to test this out! Thank you for all the hard work! Thought for a future feature... How about including Sound FX support upon teleportation? Could be useful for things like opening/closing doors, trap doors falling or floor boards breaking, creature summoning, etc. Just an idea!
@Tori/Gebo You could probably do this by also setting It's a trap , possibly to trigger the teleport. It's a trap already has a sound trigger, also (hint) the trigger in that program could possibly 'inspire' Pat .
1606413765

Edited 1606414327
Pat
Pro
API Scripter
Okay, stab idea at future work: Create a Character Sheet for all teleport tokens, so they can all be supplied with token buttons - these could include a two-way button shortcut, and a shortcut for easier association of tokens on the same page... alternately, not sure I can trigger the "select token" action from an API...  Edit: OR, I can check when a person selects "Add Link" - and if there are selected tokens, run it as normal - if there are no selected tokens, provide a "select token" interface? 
1606415489
The Aaron
Roll20 Production Team
API Scripter
There isn't a way to affect what a player has selected from the API.  Using token actions is a pretty good way to encourage tokens to be selected when commands are run as the Token Action only shows up with the token selected.  Having a "Link To ..." button which takes an @{target|Which Token do you want to link to|token_id} on the API command is a pretty intuitive way of doing it.
1606416933

Edited 1606417101
Pat
Pro
API Scripter
Thanks, The_Aaron - I'm pining for things that are not extant, apparently. I'd love to make a really intuitive interface to create teleport tokens easily.  I feel like there are a number of things missing from the API interface: Use an image from the marketplace that has already been used on a token (for teleport, enemy population, etc) implying its inclusion already as a purchased asset.  Set select (player id, token id) with some quietly failing (set player select on token on gm, map, or wall layer: fail silently, deselect other tokens) Dispatch event (artificial event emitter for API) Move GM (API interface for moving the GM view/page) Blue skying, but reeeeeealy want a per-player audio channel. 
1606417464
Andreas J.
Forum Champion
Sheet Author
Translator
Can the script currently teleport a player automatically from one "portal" to another by just moving their token to a "portal"? I see the script doesn't (yet) support movement between maps.
1606417720
Pat
Pro
API Scripter
ᐰndreas J. said: Can the script currently teleport a player automatically from one "portal" to another by just moving their token to a "portal"? I see the script doesn't (yet) support movement between maps. Yes, autoteleport is supported for connected portals.  Cross-page teleport is implemented but has run into some snags - I'm using the code that is out there already - editing "playerspecificpages" on the Campaign() object; however, it doesn't seem to split the player portrait like it is supposed to, and I can't find any support or documentation here or on the API site for it - I think because not a lot of people try it. I may poke general support from Roll20 to try and troubleshoot. 
1606417743
The Aaron
Roll20 Production Team
API Scripter
I would vote for all of those. =D  Some of it you can work around, but other things you just have to live with. Creating a Character that represents an unbound teleport pad would let GMs drag the token onto the map, you could then detect when it's created and prompt them for some options in the Chat, or give that Character Token Action Abilities for what they might want done. For Dispatch event sorts of things, we often use the Observer Pattern.  It works well for when you have specific scripts that things want to react to, though it breaks down a bit when you want more generic events.
1606418110

Edited 1606418167
The Aaron
Roll20 Production Team
API Scripter
Pat said: Cross-page teleport is implemented but has run into some snags - I'm using the code that is out there already - editing "playerspecificpages" on the Campaign() object; however, it doesn't seem to split the player portrait like it is supposed to, and I can't find any support or documentation here or on the API site for it - I think because not a lot of people try it. I may poke general support from Roll20 to try and troubleshoot.  Hmm.  I just tested it in a test game with this hardcoded script: on('ready',()=>{ on('chat:message',(msg)=>{ if(/^!move/.test(msg.content)){ Campaign().set('playerspecificpages',{ "PLAYERID": "PAGEID" }); } }); }); and it moved my test player correctly (replace PLAYERID and PAGEID as needed). In reality, you'll want to delete the player you're moving from that object and then add them back in.  And really, if they are being moved to the same page as the player ribbon, you likely want to just delete them from that object entirely.
1606419199

Edited 1606419337
Pat
Pro
API Scripter
The Aaron said: Pat said: Cross-page teleport is implemented but has run into some snags - I'm using the code that is out there already - editing "playerspecificpages" on the Campaign() object; however, it doesn't seem to split the player portrait like it is supposed to, and I can't find any support or documentation here or on the API site for it - I think because not a lot of people try it. I may poke general support from Roll20 to try and troubleshoot.  Hmm.  I just tested it in a test game with this hardcoded script: on('ready',()=>{ on('chat:message',(msg)=>{ if(/^!move/.test(msg.content)){ Campaign().set('playerspecificpages',{ "PLAYERID": "PAGEID" }); } }); }); and it moved my test player correctly (replace PLAYERID and PAGEID as needed). In reality, you'll want to delete the player you're moving from that object and then add them back in.  And really, if they are being moved to the same page as the player ribbon, you likely want to just delete them from that object entirely. I was using an older code that required setting playerspecificpages to false first... my understanding was it replaces, not augments - so it was required (if managing several players among several pages, as may happen with teleport tokens) that I'd have to pull and re-create the entire object... if that's not the case... it might be a lot easier than I figured. 
1606420396
The Aaron
Roll20 Production Team
API Scripter
You still need to pull and update the object, but you don't have to set it to anything else first: Campaign().set('playerspecificpages',{ ...(Campaign().get('playerspecificpages'), [playerid]: pageid });
1606440939

Edited 1606441138
Pat
Pro
API Scripter
Update Updated Gist to include teleporting multiple selected tokens. The logic is not there yet to move the player ribbon if all players are selected - probably want to include checking for if all * active * (online) players are moved and move the player ribbon in that case...  Edit: Next piece will have to include stacking logic which may have to check for light layer impediments... some rough and not-simple math to place tokens appropriately in square or hex maps (two variants) around the teleport pad token if it is 'occupied.'  New multi-select Gist
1606486549

Edited 1606488076
I tryied the script with a player... And it doesn't do what I expected. There is some issues only with the multipage mode. I tried the last Gist and the One Click (and also the previous Gist), both had the same behaviour. When the player's token is moved on the teleport pad, it goes to the GM layer (normal) and on the other page the token from the GM layer goes to the object layer (also normal) but the player (no matters if he is inside of the ribbon or alone) doesn't switch page. Is it normal or there is a bug ? Beside, I am wondering where/how you store data. Because every time I create a token, the number continue to increment, even after remove all scripts, deleted all teleports pads and deleted the Handout. And sometimes, some of my pages can't receive new teleport pad without making a crash of the API. I am obliged to create a new page redraw all I have done with the previous and delete the previous one... If it was possible to clear the memories, it will act like it was the first time I create a teleport pad... Is it stupid ?
Yes, I too was wondering about the pad number relentlessly incrementing. Where is that number stored, and how would one reset it?
1606490559

Edited 1606491092
Pat
Pro
API Scripter
The pad number is a state variable, just there to prevent an accidental duplication of pad names. Any time a pad is created or there is an attempt to create, it increments. Pad ids are unique as they are token ids, the number increment is just to avoid having "new pad token" as the name of a bunch of pads. It has nothing to do with the actual targeting of teleport pads.  I'm curious about this and what it means:  Nicolas G. said:  And sometimes, some of my pages can't receive new teleport pad without making a crash of the API. I am obliged to create a new page redraw all I have done with the previous and delete the previous one... If it was possible to clear the memories, it will act like it was the first time I create a teleport pad... Is it stupid ? "...can't receive new teleport pad without making a crash of the API" All of the information on a teleport pad is stored in the teleport pad. If you create a pad and link it, and then copy and paste it into a new page or into the same page, any pads linked to it will have their links "broken" unless they are unlinked and re-linked, because the new teleport token has a new token id, which is how links are managed. The pasted teleport pad will not have its outgoing links broken (they are also by token id, and those "outgoing" ids have not changed) but any pad linked to this copied and pasted pad will no longer work , as the token id of this pad is now different (part of the Roll20 create object method, to prevent a collision of object ids). None of that should require redrawing a page entirely...   So I'm curious - what's the message on the API crash, so I can troubleshoot it? 
1606490784
Pat
Pro
API Scripter
About this part - I'm still researching, as there is not a reason why the cross-page player teleport should not work, but it is not working.  I've tried several methods, but so far there is not a clue why using the same method outlined elsewhere is not working, and there is not a lot of documentation around Campaign().get("playerspecificpages"). I'm still trying to sort it out, but I don't have enough information to push a new version or patch.  Nicolas G. said: I tryied the script with a player... And it doesn't do what I expected. There is some issues only with the multipage mode. I tried the last Gist and the One Click (and also the previous Gist), both had the same behaviour. When the player's token is moved on the teleport pad, it goes to the GM layer (normal) and on the other page the token from the GM layer goes to the object layer (also normal) but the player (no matters if he is inside of the ribbon or alone) doesn't switch page. Is it normal or there is a bug ?