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

Problem or Mistake, Teleporter Script FinalFrog

1555590624

Edited 1555593424
Hello, I would like to use this script, a few days ago I created some teleporter that works perfectly but today they only work one way. And when I create new ones they don't work at all! Did I make a mistake in the handling of the script?&nbsp; Here's the problem(Click it's a gif): Here is the list of teleporters: Here is the script: <a href="https://gist.github.com/finalfrog/124f67ad84204546caf16fffd84115e4" rel="nofollow">https://gist.github.com/finalfrog/124f67ad84204546caf16fffd84115e4</a> Teleporter &amp; Faker they were the teleporters I created a few days ago. VSolitaryChamp are the new teleporter. The script is Enabled in the API, each teleporter is of course on the MJ layer, the character is addressed to a particular player (Me). Edit1: After some search i found that 2/3 week ago someone asked the same question but with an other script for teleporter.&nbsp;Should I try Aaron's script for the teleporter?&nbsp; <a href="https://gist.github.com/shdwjk/350752df3684d859f28611b1d047ad1e" rel="nofollow">https://gist.github.com/shdwjk/350752df3684d859f28611b1d047ad1e</a> I'm a little confused with the number of scripts for teleporters, which one would you advise me to use? Reading the script of FinalFrog and Aaron's script I find them both a little similar on the part I'm interested in. In addition there is a conflict in the explanations, the big comment above indicates that Teleporter02A and Teleporter02B provide a two ways door.&nbsp; "Two way doors:&nbsp; &nbsp;XXXXXXXX2A, XXXXXXXXX2B" But some comment in the code indicate that Teleporter01A and Teleporter01B do the same too : /*&nbsp; To use this system, you need to name two Teleportation locations the same *&nbsp; &nbsp;with only an A and B distinction. For instance Teleport01A and Teleport01B&nbsp; *&nbsp; &nbsp;will be linked together. When a token gets on one location, it will be *&nbsp; &nbsp;Teleported to the other automatically */
Hmm my version of this script still works fine try using the arrow keys instead of your mouse and see if it works.
After a few hours of testing, I managed to make it work but I just realized that it is mainly a problem of explanation on the use of scripts I specify: The FinalFrog's Script: &nbsp; <a href="https://gist.github.com/finalfrog/124f67ad84204546caf16fffd84115e4" rel="nofollow">https://gist.github.com/finalfrog/124f67ad84204546caf16fffd84115e4</a> -The name of the teleporter doesn't matter, the only thing that matters is the 2 digits and the letter at the end. -The grid is necessary to operate the script, without the grid the teleporter hardly fulfils its function.&nbsp; -When the grid is present it can also happen that the teleporter does not detect the token and therefore does not teleport it. The Aaron's Script: &nbsp; <a href="https://gist.github.com/shdwjk/350752df3684d859f28611b1d047ad1e" rel="nofollow">https://gist.github.com/shdwjk/350752df3684d859f28611b1d047ad1e</a> -The Name of the teleporter must "necessarily" Begin with " Teleport " which is not specified in the script comments. - Icons can be used on tokens to allow access to teleporters. Setting a "purple dot" on a teleporter will cause only tokens with a "purple dot" to be able to use it. (so it is also easy to create one-way teleporter in this way.) -The Aaron's Script seems not to cause any problems with or without a grid.(Perfect for me) So after conclusion and a lot of research I will move on to the teleporter script of The Aaron, In addition, icons can be placed on the teleporters a bit like keys, which is very interesting. And I need to operate the teleporters without the grids. On the other hand, I think it would be nice to modify the comment at the top of the script to specify these features and especially to specify that: - Names that do not start with " Teleport " do not work! Thank you for your answer Anthony V. and sorry for the inconvenience. I find it a bit unfortunate that the teleporter is limited to 9 Doors and 1 Number :c But we'll deal with it, thank you!
1555604405

Edited 1555604419
Yea the only thing I like about Finalfrogs script is that it can bring you from one page to other pages, where Aarons teleport script can not.
I did all my tests forgetting this feature which is very practical in addition to D: ... Now I'm busting my chops to choose between the two. I'm also going to have to stay on the FinalFrog script specifically for that because it was the basic source of my interest in this script.....&nbsp;
1555611804
The Aaron
Roll20 Production Team
API Scripter
There’s a complicated history to those teleported scripts. Mine is a modification of an older one, which finalfrog also modified. The original had some defects (like the grid thing) thst I corrected for my own use. I later added the key aspect to support a particular dungeon I was running. I’ve always intended to write my own, but not needed to so far. The limitation on the API creating marketplace images means a general purpose page teleport script is complicated and hasn’t risen to the top of my limited time to work on scripts lately.&nbsp; I can probably get you a fix on final fronts version for the grid issue fairly quickly.&nbsp;
1555691820

Edited 1555691920
I understand perfectly, Creating API scripts must take a lot of time and effort. So I have great respect for what you do o/&nbsp; There is no need to make any corrections, for the moment I'm content with the FinalFrog script to allow me to make teleporters in a Lobby. And I use it to make a dynamic world map. (I just finally understood that the finalfrog script doesn't like to make teleporters on the same map. And works 100% to make teleporter between maps. And so now it works xD) But if at some point you find it interesting to add an option that allows your script (with key system) to teleport characters from one map to another. I would be very interested! Thank you for your answer.
1555699410

Edited 1555699458
I come again, but this time for a bug when I want to pass my players from one map to another via a teleporter! I use the FinalFrog one :&nbsp;<a href="https://gist.github.com/finalfrog/124f67ad84204546caf16fffd84115e4" rel="nofollow">https://gist.github.com/finalfrog/124f67ad84204546caf16fffd84115e4</a> I have : - two maps " Lobby " and " Acceuil ", they are linked by two teleport tokens named " Lobby02A " and " Lobby02B ".&nbsp; - 5 Players, which I will call Player1 ,Player2 ,Player3 ,Player4 ,Player5.&nbsp; - Each player has a copy of his character on Lobby and Home I therefore complied with all operating conditions D: As soon as a player enters Lobby02A ( Acceuil ) he teleports to Lobby02B ( Lobby ) and everything is normal he can also go back without problem. But as soon as I put two players or more to play with it, a first player enters the teleporter, and the other players can't follow him as if the ghost of the first player blocks access to the Teleporter. To allow the player access again I must go to the MJ layer and move the first player's token away from the Teleporter that the other players want to use. And after that move the next player can borrow it again! To in turn block the Teleporter asking me to move the residues of its presence to the side.&nbsp; It is not a layer problem on the MJ layer because I tried to leave the tokens on the teleporter by passing them all in front or behind the teleporter without success. Does anyone know how to fix this problem? Or where it would come from? I've been looking for a while to see how you do it to see what the API is doing? I have no error messages: c
The two Maps have to have the same name and then a number for instance Lobby 1 and Lobby 2
1555704229

Edited 1555706426
After changing the names of the maps, I still have the same problem. Knowing that if there is only one player who teleports, the teleportation goes well. (Even if the maps are called differently) The problem does not appear because there is no second player to try to use a teleporter already used.&nbsp; The real problem comes from the following fact: -Player 1 and Player 2 are in MAP1&nbsp; -Player 1 passes through the teleporter, his token is transferred to the MJ layer and he changes map -Player 2 Tries to follow him and climbs on the transporter, but no teleportation. -I have to go to MJ layer on MAP1 to move Player 1 from on the teleporter. -After that, Player 2 can enter the transporter and is teleported. It's still a very strange bug, I'm looking in the code for the part that causes the token to be detected for teleportation and the part where the player token is move to GM Layer . But I'm a beginner in JS.&nbsp; Otherwise, as I said, except for this detail, the teleporter performs all its functions! Little gif of my problem: Edit2: Problem fixed,&nbsp;I added two additional lines in the code to indicate to the token that uses a teleporter and that are transferring on the GM layer to move automatically to the 0/0 position (Top left of the map). This is the js with my modification(if someone need it or have the same problem as me), idk how to keep or share a repository but i hope it's good xD <a href="https://github.com/damonreborn/API-Roll20/blob/master/FinalFrogTP.js" rel="nofollow">https://github.com/damonreborn/API-Roll20/blob/master/FinalFrogTP.js</a>
// Github: <a href="https://gist.github.com/finalfrog/124f67ad84204546caf16fffd84115e4" rel="nofollow">https://gist.github.com/finalfrog/124f67ad84204546caf16fffd84115e4</a> // // =Inspired by= // MapChange by TheWhiteWolves (<a href="https://github.com/TheWhiteWolves/MapChange.git" rel="nofollow">https://github.com/TheWhiteWolves/MapChange.git</a>) // Teleporter Without Movement Tracker by DarokinB (<a href="https://gist.github.com/DarokinB/5806230" rel="nofollow">https://gist.github.com/DarokinB/5806230</a>) // =Author= // FinalFrog // =Contact= // <a href="https://app.roll20.net/users/585874/finalfrog" rel="nofollow">https://app.roll20.net/users/585874/finalfrog</a> // // GENERAL RULES FOR CREATING AND USING TELEPORTERS: // // * Teleporters are defined by Tokens on the GM layer. // // * Tokens for Teleports must end in two digits followed by a letter between A and L. // Example: "TeleportToken02A" // // * Teleporters will only teleport tokens which meet the following requriements: // 1. Token represents a character controlled by a player. // 2. Token is on the object layer. // 3. Token with the same name exists on the page being teleported to. // // * The string preceeding the two digits and letters defines a unique teleport chain and all // teleporters in a chain must have the same two digits. // Example: "TeleportToken02A" and "TeleportToken02B" are both members of the "TeleportToken" chain // // * The two digits shared by all members of a chain define how many teleporters the chain will expect to find // before looping back to the first. // Example: "TeleportToken02A" will take you to "TeleportToken02B" which will take you back to "TeleportToken02A" // // * If an expected link in the teleporter chain does not exist then the teleport will break on the last // existing expected teleporter in the chain. // Example: If only "TeleportToken04A", "TeleportToken04B", and "TeleportToken04D" exist, then "TeleportToken04B" will teleport anywhere. // // EXAMPLE OF HOW TO CREATE AND USE AN SIMPLE TWO-WAY INTRA-MAP TELEPORTER PAIR: // // 1. Create a token on the GM layer named "Teleport02A" // 2. Create a token on the GM layer named "Teleport02B" // 3. Create a token on the Object layer named "Traveler" // 4. When you move "Traveler" into the same space as "Teleport02A" it should jump to "Teleport02B" and vis versa. // 5. You can change this to a one-way teleporter pair by naming the teleporters "Teleport03A" and "Teleport03B". // // EXAMPLE OF HOW TO CREATE AND USE AN SIMPLE TWO-WAY INTER-MAP TELEPORTER PAIR: // 1. Create a map named "MAP 1" // 2. Create a map named "MAP 2" // 3. Create a token on the GM layer in "MAP 1" named "Teleport02A" // 4. Create a token on the GM layer in "MAP 2" named "Teleport02B" // 5. Create a character controlled only by a player (Eg. Jeanie). // 6. Create a token on the Object layer in "MAP 1" named Jeanie and set it to represent the above character // 7. Create a token on the Object layer in "MAP 2" named Jeanie and set it to represent the above character // 8. When you move the Jeanie token on "MAP 1" onto the same space as "Teleport02A", the player (Jeanie) will be // moved on their own to "MAP 2" and their token on "MAP 2" will jump to the location of "Teleport02B", and the // Jeanie token on "MAP 1" is now moved to the GM layer // 9. Moving the token off of "Teleport02B" and back will reverse the process and take the player (Jeanie) // back to "Map 1", move the "MAP 2" token to the GM layer, and move the "MAP 1" token to the Object layer. var MapTeleporters = MapTeleporters || (function() { 'use strict'; // Special thanks to The Aaron for this function 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 &lt;= cx &amp;&amp; cx &lt;= or &amp;&amp; ot &lt;= cy &amp;&amp; cy &lt;= ob &amp;&amp; o.get('name') != "" ){ m.push(o); } return m; },[]) .value(); } return []; }; var handleGraphicChange = function(obj) { if (obj.get("layer") !== "objects") { return; // Only teleport tokens on the object layer } // Check for token controlled by only one player var characterId = obj.get("represents"); var characters = findObjs({ _type: "character", _id: characterId, }); if (characters.length == 0) { // No characters found return; } // Handle first matching representing character var character = characters[0]; var controllers = character.get("controlledby"); if (controllers == "") { return; } /* 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 */ // Find any teleporters in the same location as moved token var sourceTeleporters = findContains(obj,"gmlayer"); if (sourceTeleporters.length == 0) { // No source teleporters found return; } else { // Handle first matching source teleporter var sourceTeleporter = sourceTeleporters[0]; var sourceOffsetX = sourceTeleporter.get("left") - obj.get("left"); var sourceOffsetY = sourceTeleporter.get("top") - obj.get("top"); // Store the page of the source teleporter var sourcePage = sourceTeleporter.get("_pageid"); // Get name of current teleporter var CurrName = sourceTeleporter.get("name"); var Letters = new Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"); // Number of doors in the cycle (second to last character) var doorCount = CurrName.substr(CurrName.length - 2, 1); // Current Letter of the Door var currDoor = CurrName.substr(CurrName.length - 1, 1); // Finds the pair location and moves target to that location var i = Letters.indexOf(currDoor); if (i == doorCount - 1) { i = 0; } else { i = i + 1; } var NewName = CurrName.substr(0,CurrName.length - 2) + doorCount + Letters[i]; var destTeleporters = findObjs({ _type: "graphic", layer: "gmlayer", //target location MUST be on GM layer name: NewName, }); if (destTeleporters.length == 0) { // No destination teleporters found return; } else { // Handle first matching destination teleporter var destTeleporter = destTeleporters[0]; // Coordinates of destination teleporter var NewX = destTeleporter.get("left") - sourceOffsetX; var NewY = destTeleporter.get("top") - sourceOffsetY; // Page of destination teleporter var destPage = destTeleporter.get("_pageid"); if (destPage == sourcePage) { // Handle intra-page teleports by just changing position of // original token. obj.set("left", NewX); obj.set("top", NewY); } else { // Handle inter-page teleports by searching for graphic token // on destination page with same name as teleporting token var teleportedTokens = findObjs({ _pageid: destPage, _type: "graphic", name: obj.get("name"), }); if (teleportedTokens.length == 0) { // No tokens with the same name as teleporting token found return; } else { // Handle first matching teleported token var teleportedToken = teleportedTokens[0]; // Update teleported token on new page with coordinates of // destination teleporter teleportedToken.set("left", NewX); teleportedToken.set("top", NewY); // Show teleported token if it is hidden teleportedToken.set("layer", "objects"); var controllerArray = controllers.split(); if (controllerArray.length == 1) { // Teleport player to the page with the destination // teleporter teleport(controllerArray[0], destPage); // NOTE: sendPing moveAll argument currently broken (See <a href="https://wiki.roll20.net/Talk:API:Utility_Functions" rel="nofollow">https://wiki.roll20.net/Talk:API:Utility_Functions</a>) sendPing(NewX, NewY, destPage, null, true); // Hide original token if player has moved to new map obj.set("layer", "gmlayer"); } } } } } }; var teleport = function(playerId, pageId) { var playerPages = Campaign().get("playerspecificpages"); if (playerPages === false) { playerPages = {}; } if (playerId == "all") { // Move the whole group to the target page Campaign().set("playerspecificpages", false); Campaign().set("playerpageid", pageId); } // Remove player from playerPages if (playerId in playerPages) { delete playerPages[playerId]; } // Update playerPages with player on target page playerPages[playerId] = pageId; Campaign().set("playerspecificpages", false); Campaign().set("playerspecificpages", playerPages); }; var registerEventHandlers = function() { on('change:graphic:left', handleGraphicChange); on('change:graphic:top', handleGraphicChange); }; return { RegisterEventHandlers: registerEventHandlers, }; }()); on("ready", function() { 'use strict'; MapTeleporters.RegisterEventHandlers(); }); Heres the copy I am using if this helps at all, I don't seem to have the same layering issues.