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 Request/Question] Teleport Script

April 23 (3 months ago)

[Legacy Roll20]
So I've used the Teleport Script by Patrick K, it's great! However I was wondering if there was any way to alter or make something that does what I need.


I was wondering if it was possible to create tokens on new maps, instead of having to have them gm layered on every map.
(I used custom tokens/custom everything) So that way its easier and I dont have to keep pasting player characters on every single map.

Another thing:
I have several items that I can group to player tokens to look like item wear, hats, ect. Just a fun little thing. But the problem is, you can't teleport to a new map with grouped items on your token using the Teleport Script. Even if the grouped item is on the next map, it defaults to the center of the player token, and not where it was grouped on the previous map. I just want players to be able to group hats on their player tokens and move from map to map without it moving or taking off. And if they do ungroup it, it comes off on every other map they teleport to. Is there any way to get that working? Thanks!

April 23 (3 months ago)
Pat
Pro
API Scripter

Kind of fortuitously, I'm currently working on two things. 
One of them is using opacity instead of jumping layers if it's available (Jumpgate vs. Classic), the other is duplicating tokens if it's available (Experimental Jumpgate only) 

Teleporting grouped objects might be a future thing, when groups can be allocated and moved all together by script... right now, it can't detect if objects are grouped and move "up" or "into" a hierarchy of grouped objects. 

Since I'm working just in-game, I'll post a new version that might support the first two properties on my github. It'd have to be tested before it could be moved to the library. 


April 24 (3 months ago)

Edited April 24 (3 months ago)

Oh that's lovely to hear, thank you for the reply!

Though it is rather unfortunate to hear that grouped object positioning can't be detected! Hopefully something like that can be added in the future, it seems like a neat idea and could make way for some other unique uses! 

I'd love to test out any new releases.
Thanks for your time! 

April 24 (3 months ago)
Pat
Pro
API Scripter

Here is the new release - it has some future proofing in it, hopefully, as it attempts first to find an existing token on the page (so you don't constantly generate new tokens all the time), then it tries the experimental branch token copy, then if that fails it tries the fallback graphic creation, which if that fails because of asset limitations (not your own upload) it fails to the standard "no token found on destination page" 

https://github.com/Gritmonger/teleport_revised/blob/main/teleport.js

April 24 (3 months ago)

Great!
I'll be doing some extensive testing with this in my next coming session this weekend- currently it seems to be working as intended!
Thank you very much. 

April 26 (3 months ago)

Edited April 26 (3 months ago)
Pat
Pro
API Scripter

A warning on the current script: it has a quirk related to tokens that don't have an associated character sheet trying to teleport page to page - I'm working on a fix for that, but this bug likely exists in the uploaded version too. Currently, tokens *within* a page don't have this problem, and any token can teleport within a page with no difficulty. Where tokens need to be found or created (going page-to-page), un-represented (non-character-sheet having) tokens cannot be teleported. This sometimes resulted in a teleport token being shifted to the token layer, a non-desirable outcome. So I'm putting in a temporary fix, and might refine the fix to exclude teleport tokens from the list of searchable tokens by other means as well. 

This also means if you have more than one token represented by the same character sheet that page-to-page teleport will only ever teleport one of them currently. So five orcs represented by the same character sheet cannot teleport page to page, as only one of them would ever go ("Hey, I found your character! Hey I found the same character, again! Hey, I found him again!") 

This goes with another aspect of teleport currently which is a player goes to the new page as soon as one of their controlled characters teleports. For players that control a character and a mount or a pet, this is currently a problem. So there may be room for putting in a toggle to query whether to teleport a player too (move their ribbon to the new page) This could result in stranded characters if a player says "no" when they only have one token on a page, but that's a development problem. 

This also brings up the "crowding" problem at the destination site (in-page and cross-page) - if I put in a spreading algorithm, it would mean mounted characters would be dismounted on teleport. Etc. 

April 26 (3 months ago)

Edited April 26 (3 months ago)
Pat
Pro
API Scripter

Going to try something new where, if either the graphic has no sheet or even if the graphic has a sheet, it will also check the name attribute of the object for a match. This should allow *named* graphics that are either repeats of the same character sheet or which have *no character sheet at all* to also page-to-page teleport without creating unnecessary duplicates.

I'll try and post that to the original link and start a new thread for "Teleport Improvements" once I do two more things and that's get the player ribbon re-combining and matching set status markers on the target element if it's already present.  


Okay, I have preliminary code for duplicating graphics with no owner and no character sheet provided they have a name... if a token doesn't have a name or a character sheet it won't teleport because there is no way to tell it from any other random graphic or prevent it from duplicating infinitely. If a token has a character sheet, it will check to see that the name matches so as long as tokens are named uniquely, they will each uniquely teleport. So you can have orc1, orc2 and orc3 that all point to the same sheet and have them teleport uniquely. 

I will be using ver. 1.2.4 tomorrow afternoon in my long running campaign. I don't know if any of the players will try and teleport or not but if they do and something goes wrong I will report it here.

April 28 (2 months ago)

Edited April 28 (2 months ago)
[Using the version you linked to initially]
Most of the tokens on my maps are connected to a sheet, so most of it went perfectly fine. There was once or twice I had accidentally teleported a token without one, but it actually teleported perfectly fine with no notable issues on my end. No teleport tokens changed to the token layer.

So for my session and further testing, it worked as intended for me. From teleporting multiple tokens at once, single tokens, tokens without sheets. I suppose I was just lucky not to run into any issues regarding the cross page teleport and tokens without character sheets. 

I will be following that thread and updating to your newest version as well and test it for next session! 
April 28 (2 months ago)
Pat
Pro
API Scripter

Okay, I'll be updating the notes: the constraints on cross-page teleport relate to being able to find a matching token if one already exists, so the way to find a matching token is either by unique name or by associated character sheet and unique name. So if you teleport a whole passel of orcs with the same name associated with the same character sheet, only one of them would teleport and the rest would re-use the token that has the same name and character sheet. Tokens without character sheets *have to have unique names* - if they don't have a name, they won't cross-page teleport. They'll still same-page teleport, because no tokens are created or destroyed in doing so. 

April 30 (2 months ago)

Edited April 30 (2 months ago)

The issue I am seeing is when there are multiple destination pages for one telepad. When I move a token onto the source telepad I am not getting a choice of destinations. Instead it is teleporting the token to the first destination telepad and deleting the other destination links.

April 30 (2 months ago)

Edited April 30 (2 months ago)
Pat
Pro
API Scripter

Can I ask a few more details?
- Are the multiple links a mix of same-page and cross-page teleport targets?

- Are you selecting the "select" option instead of "random" for all pads or just one pad?


Update: Okay, I was able to replicate it, but... when I put in log calls to trace it... it suddenly started working. So... 
I'll continue testing, but if it continues to work without failing I'll have to figure out why it's failing and then put in a permanent fix - hoping to have that soonest. 

May 01 (2 months ago)
Pat
Pro
API Scripter

Okay, looks like the overhaul is going to be a bit deeper - I'm going to have to do some transformations of arrays to strings, among other things, just to make sure everything is reconciled based on where I'm storing data (within the teleport tokens) - so using properties of tokens comes with problems if you try and set values to *other than strings*. 

Due to this, I won't have a ready reconciled version ready tonight, it might be a few days of internal testing before I can distribute a new version, and I may have to have a global function that checks and validates all token values as Strings, and converts them if they are not. 

May 02 (2 months ago)

I was able to replicate the multiple destinations bug without fail, as in it only teleporting you to the first destination. It will not work as intended it seems. 

But thank you for your diligent work and I'm looking forward to the overhauled version. 

May 02 (2 months ago)
Pat
Pro
API Scripter


FurryOwO said:

I was able to replicate the multiple destinations bug without fail, as in it only teleporting you to the first destination. It will not work as intended it seems. 

But thank you for your diligent work and I'm looking forward to the overhauled version. 


Here's the funny thing: I can "fix" it by logging the list of destination portals *first* - which shouldn't change anything, but it does - so I'm suspecting it is in the string-Array transition (storing Arrays directly into these tokens used to apparently do a weird kind of "stringify" ) but because it's playing fast and loose with data types, I'm going to have to convert to stringify and parse to translate arrays into the string data type storage, but because there are users currently who have data stored as strings, I'm going to have to either put in a purge or rectify setting to fix legacy items, or make it backward-compatible. 



May 07 (2 months ago)
Pat
Pro
API Scripter

Okay. 

I'm not 100% sure this is 100% working properly... 

BUT


So far in my own testing this proper stringify-array conversion appears to work. I'm waiting to hear back from folks on whether it solves the issues with cross-page multiple-target teleport scenarios. 
https://github.com/Gritmonger/teleport_revised/blob/main/teleport.js


May 07 (2 months ago)
Pat
Pro
API Scripter

Next aspects: 


May add: audio on teleport (maybe) - I'm looking at how to play sounds and how to store a sound file on a token as a string - there is still one or two string slots left, due to the way this was initially coded, there are a number of binary/switch slots left for other properties. This would involve creating a sound library index and a way to access sound file labeling in a user's library. This might be simple, this might be complicated, I'm not promising it yet. 


May add: Player accessible destinations, this may depend on a binary (all players have access, not just some) which can still be gatekept by specific token selections/keys or deactivation (a GM can deactivate a token at any time through the edit interface). 


Adding: opacity to 0 while on GM layer to avoid a stack of little shadows for limbo tokens for GM, reversion to Opacity 1 after completing teleport cross-page. Opacity to 0 is only for cross-page and limbo tokens. 


May 08 (2 months ago)

Thanks for all your work, Pat!

July 06 (2 weeks ago)

Edited July 06 (2 weeks ago)

Curious, any update on adding sounds?

July 08 (2 weeks ago)
Pat
Pro
API Scripter

Pause is wanting to look at how others are invoking sound, at timing (it can be really off for teleport + effects, so adding sound I'd need to make sure the timing isn't waaaaay off). 

Also, there are bugs reported, and bugs take priority over new development.