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 .
×

Teleport Script Problem

I can't seem to get the Teleport Script from&nbsp; <a href="https://app.roll20.net/forum/post/4694539/teleport-script-tweaked" rel="nofollow">https://app.roll20.net/forum/post/4694539/teleport-script-tweaked</a> &nbsp;to work. I do not claim to be a coder, and I do not take any credit for creating this script.&nbsp; <a href="https://gist.github.com/lazy468/93744539abf8f1895e89a176fa84512e" rel="nofollow">https://gist.github.com/lazy468/93744539abf8f1895e89a176fa84512e</a> &nbsp; For the sake of safety, I made a copy of my game to test the script, and it worked like a charm. But when I tried to use the script in the main game, it just refuses to work and keeps giving me the following message when I try to start it up:&nbsp; &nbsp; &nbsp; TypeError: Cannot read property 'set' of undefined &nbsp; &nbsp; TypeError: Cannot read property 'set' of undefined &nbsp; &nbsp; &nbsp; &nbsp; at CreateMacro_TP (apiscript.js:183:25) &nbsp; &nbsp; &nbsp; &nbsp; at apiscript.js:26:3 &nbsp; &nbsp; &nbsp; &nbsp; at eval (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:151:1), &lt;anonymous&gt;:65:16) &nbsp; &nbsp; &nbsp; &nbsp; at Object.publish (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:151:1), &lt;anonymous&gt;:70:8) &nbsp; &nbsp; &nbsp; &nbsp; at checkForReady (/home/node/d20-api-server/api.js:1438:12) &nbsp; &nbsp; &nbsp; &nbsp; at /home/node/d20-api-server/api.js:1518:9 &nbsp; &nbsp; &nbsp; &nbsp; at c (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:14:64) &nbsp; &nbsp; &nbsp; &nbsp; at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 &nbsp; &nbsp; &nbsp; &nbsp; at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) &nbsp; &nbsp; &nbsp; &nbsp; at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546) I have not altered the script in any way to my knowledge, and I have no clue what this error code means, considering it only shows up in one of my games but not the other. I am using the same script for both the copy of my game and my original game. So I am sorry about the stupid question, but how do I fix this error?
1553977220
The Aaron
Roll20 Production Team
API Scripter
The function "CreateMacro_TP()" is the problem.&nbsp; It makes flawed assumptions about the existence of the macros and is trying to set the action of one that doesn't exist yet.&nbsp; Change the beginning of it to this (starting at line 108): function CreateMacro_TP () { var tp_macro = (findObjs({ _type: 'macro', name: 'teleport' })[0]||createObj('macro',{name:'teleport'})); var tp_all_macro = findObjs({ _type: 'macro', name: 'teleport-all' })[0]||createObj('macro',{name:'teleport-all'})); and it should prevent the crash.
1553982032

Edited 1553983590
Thank you Aaron! It did prevent the crash like you said it would.&nbsp; EDIT: It looks like there is a rogue ) floating around in the code somewhere though. Now I am getting: &nbsp;&nbsp;&nbsp;&nbsp;Syntax Error: Unexpected Token )
I legitimately have no idea why this isn't working. I copy/pasted the code directly from the campaign it works in, and in this other campaign, it does not work, even with your edits Aaron. I am running another script, but even with the other script disabled, the same error message came up, making me think the other script is not interfering. I tried to narrow down problems by placing bits from the script that is not working (in the actual campaign) into the one that does work (the campaign copy) to see if there was a specific portion I should focus on, but the copy still worked all the way through.
1553991878
The Aaron
Roll20 Production Team
API Scripter
Hmm. I’ll see if I can get a better fix for that.&nbsp;
1553994607
The Aaron
Roll20 Production Team
API Scripter
So, do you use all the additions from that thread? (Ping teleport location, FX at teleport, Emote for Teleport, etc) If you don't, I have an updated version of the original teleport script you can use:&nbsp; <a href="https://gist.github.com/shdwjk/350752df3684d859f28611b1d047ad1e" rel="nofollow">https://gist.github.com/shdwjk/350752df3684d859f28611b1d047ad1e</a>
1553994682
The Aaron
Roll20 Production Team
API Scripter
The Aaron said: Hmm. I’ll see if I can get a better fix for that.&nbsp; Here's the fixed lines: function CreateMacro_TP () { var tp_macro = (findObjs({ _type: 'macro', name: 'teleport' })[0]||createObj('macro',{name:'teleport'})); var tp_all_macro = (findObjs({ _type: 'macro', name: 'teleport-all' })[0]||createObj('macro',{name:'teleport-all'}));
The fixed lines still did not work either. I am still getting the same error as before. As for the additions, I can live without the fancy FX or emotes, but I would like to keep the ability to turn them on or off with the Red X marker. I tried to replace it with the original teleport script, and it isn't crashing, but none of the commands are working for some reason.
1553996378
The Aaron
Roll20 Production Team
API Scripter
That X works in my version of the script.&nbsp; You can also set "keys" by putting statusmarkers on the teleport pads.&nbsp; Only characters with matching statusmarkers (including the numbers) will be teleported by them.&nbsp; In my game, they had to find rings that let them use a portal.&nbsp; When they had one, I'd put something like green:6 &nbsp;on them and then they could use the teleport pads with a green:6 &nbsp;status marker.&nbsp;
I've decided that your script will work perfectly for my purposes, if I can get the Autoteleporter function to work.&nbsp; I have set up the teleporters as I am supposed to, (One named Tele02A, the other Tele02B) and Autoteleporter is enabled. So to try and test it out, I moved a player's token on top of one of them, and nothing happened. I placed them on top of the other, and nothing happened either. I also tried the standard teleport command "!Teleport (Char),Tele02A" and that didn't work either. Am I missing something in your script?
1553997252
The Aaron
Roll20 Production Team
API Scripter
I think mine expects them to be named "Teleport&lt;SOMETHING&gt;&lt;NUMBER&gt;&lt;LETTER A-J&gt;".
Got it! thank you for the alternative Aaron.
1553998002
The Aaron
Roll20 Production Team
API Scripter
No problem!