Trigger Happy (Teleportation Tutorial)

Hello! It seems that a lot of people liked the idea of teleportation, This small post teleports the “token/player” to a separate place. It can be on another scene, and the player will follow. Troubleshooting is at the bottom if you need any further help.

As that is covered, some things to go over:

Modules

Modules 0.8.*

Have Trigger Happy Installed.
Have Advanced Macros Installed.
Have Dynamic Active Effects Installed.
Have a Journal Entry named Trigger Happy.

Modules 0.7.*

Have Trigger Happy Installed.
Have Furnace Installed.
Have Dynamic Active Effects Installed.
Have a Journal Entry named Trigger Happy.

image

Macro - Start here

To start off, make a macro.
Name it: TeleportToToken
Make sure it is set to: Script
Disable Execute Macro As GM

Dynamic Active Effects
DAE.teleportToToken(token, args[0], args[1], args[2])
Dynamic Effects
DynamicEffects.teleportToToken(token, args[0], args[1], args[2])

Save.

Note:

You don’t have to change anything here. We’ll be using it later.
image

Actor

Now we have to make an actor. Create a normal character. Name it anything you want. For this tutorial, we’ll call this Stairs.

Now, before we put this character on the board, we need to unlink it.
For this tutorial, we’ll also change the token of this character to a transparent picture.

Tip: While we’re here, put Display name to Owner, this will help you recognise what token you’re trying to teleport later. Thank me later.

Note: You only need this 1 Actor from now on. No need to clutter your Actors directory

Token

Now, drag this Actor onto the board. Then Double Right-Click on it. This should bring up Token Configuration again.

This is going to be our Teleportation from token, so I’ll name it Stairs1 For this tutorial.

image

Now we are done with the Teleporting From Token. Place this where you want them to teleport from as they step onto it.

Tip: After you’ve placed the Token, you can make it bigger by changing the Width/Height values in Image

Endpoint/Other Side
So now that we have a place to teleport from, we need a token to teleport to. This token can be made on a new scene, or on the same scene if wanted. Drag the previously made Actor of Stairs Onto the board once more, make sure you place it where you want the Player/user to land.

Double Right-click this new Token, and re-name it. For this tutorial, we’ll call this one Stairs2.

You can make the same changes to this token as to the last one.
Now we have an endpoint.

Trigger Happy

Now we get to the Trigger Happy part of this, which should be fairly straight forward.
Now that we’ve made our tokens, Stairs1 and Stairs2, we’ll use them here. What I’ll input into The Trigger Happy Journal Entry is(ctrl-shift-v to clear formatting on paste):

@Token[Stairs1] @Trigger[capture move] @ChatMessage[/TeleportToToken Stairs2 0 0]

@Token[Stairs2] @Trigger[capture move] @ChatMessage[/TeleportToToken Stairs1 0 0]

To explain the above text:

@Trigger[move] means "when someone Moves ONTO this @token[Stairs1]
This will happen: @ChatMessage[/TeleportToToken Stairs2 0 0]

It sends a Chat message: /TeleportToToken Stairs2 0 0
Where TeleportToToken is the Macro we created. Stairs2 is the token we’re teleporting TO.
The 0 0 Is offset, Where the first 0 is X and the second 0 is Y

The second line is for “moving back”. As these are stairs, I want my players to move back too, therefor I switched the token names, so when someone steps onto Stairs2 they get teleported to Stairs1.

From here on out, you can edit names of stairs as you want, but it should teleport any token that steps onto the Token(s).

Random Room Teleporter

To create a random room teleporter with the above context, it is easy.
To start off you’ll have to have the 2 characters, just like above.
Place a token they have to step onto to teleport to a random room.
Rename it, as shown above. In this example, we’re going to call ours Wildcard Portal.

Now, we need to make a Roll-table.
In this example, I’ll call this roll-table: Room Table
In this Roll-table, we’ll put in our different rooms. They all have to be text.
Room1
Room2
Room3

These are going to be our Exit Tokens Name.
So place out the token they where you see fit, at the entrance of the random room(s).
Re-name them after 1 of the options in the Roll-table.

Macro
Now we’ll make the macro to be used as the random teleport
Name it: RandomMap
Make sure it is set to: Script
Disable Execute Macro As GM
Macro:

let table = game.tables.entities.find(t => t.name === 'Room Table');
let result = table.roll().results[0];
DynamicEffects.teleportToToken(token, result.text, 0, 0)

image
Room Table Is the name of the Roll-table we made earlier.

Trigger Happy
Now for Trigger Happy, just as the previous one for the normal teleport, we need to execute this macro instead.

@Token[Wildcard Portal] @Trigger[move] @ChatMessage[/RandomMap]

Where @Token[Wildcard Portal] is the token we’re teleporting from, and /RandomMap is what we named the macro.

image

Now, if you want these room to teleport to another random room, like let’s say a tower, you’ll have to make a Exit Token, and a Entrance Token for each map/floor. So the entrance tokens needs to be re-named individually, like Floor1, Floor2, Floor3, and the exits also needs to be named individually:
Wildcard1, Wildcard2, Wildcard3.
They all also need to be put into Trigger Happy individually.
It will cause problems to just put out a token with the same name, so just trust me. It is less confusing, a bit more work, and won’t cause bugs.

Troubleshooting


Problem 1 - Token Stuck after teleportation/Copies of Token 1
Make sure, if you’re using a folder for Trigger Happy, that the Journal you’re using is not named “Trigger Happy”. This will make the token teleport twice and make some weird bugs. Just re-name the Journal Entry.


Problem 2 - It doesn’t teleport/Doesn’t work correctly
Text Formatting might’ve followed. Go into Source code and delete the formatting.
To get to source code, press <> while editing the text.

If you have any doubts of what should be there, here is a “normal” one:

Remove anything along the lines of:

<span style="background-color: rgba(27, 31, 35, 0.05); color: #24292e; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace; font-size: 13.6px;">

Problem 3 - Copies of characters 2
If you’re struggling with copies of characters being spawned, you might be struggling with multiple tokens with the same name. If the teleportation tokens have copies, they will spawn copies. Each Token Needs a different name, both Sender and Reciever Teleportation token.

Reason

If your trigger happy specification (or indeed your macros) call DynamicEffects.teleportToToken more than once for the same actor token you will get new copies of the token for (up to) the number of times you called the function. The teloportToToken function does the following:
1. find destination token (the argument to the teleportToToken function)
2. create a copy of the actor token at the location of destination token found in step 1
3. activate scene where the destination token exists (might be the same scene)
4. delete original actor token
If you call the function more than once (and the delete has not yet happened) it will create another copy of the actor token.

The function is supposed to be executed by the player whose token is to be teleported. Usually that means you want you player to step onto/activate the teleport. If you do it as DM then the scene change will happen for YOU not the player, (the token will still be created and then the original deleted) and when the token is deleted the player will be informed they have no token with vision and the scene will go black.

The whole teleport thing works without the GM being present on the scene where the teleports activate. So you can have players on different scenes as they move over teleports. This is the way it is supposed to work. I have had the party spread out over 3 different dungeon levels as they try to go up and down stairs.

@tposney


Any other problems?

You can either leave a comment here, in Kakarotos Discord Server, or in Foundrys #Module-Discussion. Just ping @Kevin-#0001 Or @kakaroto.

2 Likes

Hi,

Love the teleport, they work great.

One small problem I have experienced is that when a player goes through a teleport to another map, they token is deleted and re-created, the new scene is loaded however the player can’t pan their map.
The fix at the moment is that if they click anywhere off the map (side bar, top of the browser, off screen) they can then pan the map. But if they teleport and then immediately try to pan the map once the screen has switched it does not work. There are no errors being thrown in the console. Any ideas what could be causing this? I have a feeling this is something to do with the way FoundryVTT is executing this code, but wondering if there is anyway we can stop this from happening, its not a game ender but is annoying for my players.

Thanks!

I believe that was a core bug in Foundry 0.6.0, updating to 0.6.2 should fix the problem. Make sure you haven’t set your Game to use a specific version of Foundry and it should auto update the next time you launch it.

I am currently using Core 0.6.2 but still having the issue occur. I’ll inquire about it in the Foundry discord. Thanks.

Weird, last person with that issue confirmed updating to 0.6.2 fixed it for them. Make sure another module is not causing the problem, then check with the foundry support if that doesn’t help. Might be hard to debug since it’s a pretty specific situation that happens through a module rather than from a core feature, so not sure how much more help they could give as well.

That was a foundry bug, which has now been fixed. It was the same problem if you pulled a token to the scene. And it was not fixed in 0.6.2, from recollection not until 0.6.4 but I could be telling a fiv.

Foundry 0.6.5
TriggerHAppy 0.5
DynamicEffects 0.5.76
Furnace 2.1

Hello there @mbenson111 ! It looks like you’re running into testing problems by yourself?
That is an error for: A GM not being online.
Dynamic effects need a GM to be online to work, therefore I recommend having a second tab open(ctrl + shift + n) where you can test as a player and a GM at the same time.

If you’re further running into this problem, it happens because a player loads before a GM.
I would recommend just connecting as the GM before all your players.

Why it teleports the player to that scene is because it doesn’t actually need GM permission to switch scene.

Hope this helps ^^

Thank you. That was it.

HI all, for some reason the basic example above isn’t working for me… it says there is a syntax error in the macro…

I’m using DAE, and have followed the example above to a letter – but macro says there’s a syntax error.

The only thing I can’t figure out in the example above is the statement " Disable Execute Macro As GM"

I don’t see a setting for this…

Also, my version of DAE is 3.0.4 and FVTT = 0.7.8

thanks,
c

  • I figured out with the new update, DAE i integrated into the compendium… and now I have it working, except for some reason the token is not deleted from the ‘origin’ scene… although a new token is created in the new scene (destination). resulting in two tokens for same actor in the game…

the chat says “No token selected” when I move a token onto the trigger token… ??

If you see the screenshot I provided: image

There is a are saying “Execute Macro as GM” then a box to the right.
It means it shouldn’t be tagged off. as shown in the picture.
If you don’t have that button, you would need Furnace, the module.

I have not tested with 0.7.8 yet though. So we’ll see.
Try 0.7.7 if you can ^^

thanks Kevin, I got it ‘semi working’ – using the built in DAE examples - but it’s saying ‘no token selected’ … im logged in as a character and dragging their token onto the trigger… the trigger runs (because the scene change to the destination scene) but it seems the built in macro must be failing… since it’s spitting up that error… the first line of the macro is:

“if (!token) return ChatMessage.create({content: No token selected})” – so for somereason the token information isn’t getting passed… any ideas?

tried putting both ‘stairs1’ token and ‘stairs2’ token inside same scene…and still won’t work… the player token simply doesn’t delete/reappear… frustrating.

and the macro had to be done ‘as GM’ since it was trrowing an error “[player] does not have permissions to create token”

update - almost there – I have it working for teleport within a scene… and ‘almost’ for teleport between scenes… the only remaining glitch is that the token moves to the new scene… but the focus does not shift with them… e.g, the screen goes dark (no vision) for the scene they were in… moves their token to te new scene, but then stops… so they have to manually click the navigation bar to see the new location…

So, just as a reference: A GM would need to be logged on for this to work at all.

DAE relies on that. So what I would recommend is actually testing with a player, or logging in with an incognito tab. (ctrl + shift + N on chrome).

It would also help me a lot if you sent the Trigger Happy and macros :smiley:

thanks again Kevin - any help/advice would be welcome.

to help me trouble shoot the problem, I created 3 portals in 2 scenes.
the first two portals are in opposite sides of the same room (so it’s easy to see if it works).
the first two portals (in same scene) work great!

it is the teleport between scenes that’s not working right… it’s not consistent (and not sure why). It does seem to always place the new token in the new scene…but it does not switch view automatically to that new scene *(the character player has to click on the navigation bar or the DM has to activate the scene… ). but sometimes (not always) the original token is not deleted … and remains in the origin scene AND appears in the new scene… (duplicate tokens). This causes a problem if the player re-teleports back to the room again… now there are two tokens… and if I do it too quickly… it can cause some strange loop that breaks the connection with the game… (has to be reloaded). Also, occasionally an error message saying ‘you do not have a character token with vision in this scene’

my set up: I have both the DAE and Furnace modules installed/enabled

  1. goal to have three portals in two scenes

a. portal01 (in scene: “tomb”) —> portal02 (also in scene: “tomb”)
bl portal02 (in scene: “tomb”) —> portal03 (in scene: “watergrave”)
c. portal03 (in scene: “watergrave”) —> portal01 (in scene: “tomb”).

  1. token creation

all the portals are tokens from the same actor: “teleporttoken” with the token name changed to: portal01, portal02 and portal03.

  1. Trigger Happy

in a folder called “Trigger Happy” is a journal entry called: “Triggerportals”
with the following code:

@Token[portal01] @Trigger[capture move]@ChatMessage[/TeleportToToken portal02 -2 -1]
@Token[portal02] @Trigger[capture move]@ChatMessage[/TeleportToToken portal03 -2 -1]
@Token[portal03] @Trigger[capture move]@ChatMessage[/TeleportToToken portal01 -2 -1]

  1. macro

in my macro bar is a macro called “TeleportToToken” – which was dragged there (no edits) from the “Sample macros” folder that was installed with the DAE module (pasted below).:

  1. if I can’t solve it, I might just give up on ‘teleport between scenes’ and put the two maps on the same scene… separated by walls so players cannot see between them… but ideally it would be nice to be able to truly teleport between the scenes – as I can think of of some really fun elements of the game if I can implement it without having the players navigate themelves… (it is clunky to even have the scenes visible in the nav bar…and would rather players just move between scenes with DAE events (doors, teleports, etc) so it would be wonderful if the target scene automatically changed when the trigger code ran.

thanks!

-c

(macro pasted below):


let targetScene;
if (!token) return ChatMessage.create({content: No token selected})
for (let scene of game.scenes.entities) {
var targetToken = scene.data.tokens.find(t => t.name === args[0]);
if (targetToken) {
targetScene = scene;
break;
}
}
if (!targetScene) return ChatMessage.create({content: Could not find token ${args[0]} in any scene});
CanvasAnimation.terminateAnimation(Token.${token.id}.animateMovement);

let x = targetToken.x + targetScene.data.grid * (args[1] || 0);
let y = targetToken.y + targetScene.data.grid * (args[2] || 0);
let startScene = canvas.scene.id;

await game.macros.getName(“createToken”)?.execute(targetScene.id, x, y, token.data)
if(targetScene.id === startScene) {
await game.macros.getName(“deleteToken”)?.execute(startScene, token.id)
} else {
Hooks.once(“canvasReady”, () => {
game.macros.getName(“deleteToken”)?.execute(startScene, token.id)
})
await targetScene.view();
}
canvas.pan(x,y)

// This macro is intended to be used with Trigger Happy and requires Furnace advanced macros to run.
// Sample trigger happy setup.
// You must place two tokens on some scene(s). They must have unqiue name (not actor name, but token name).
// @Token[Target1] @Trigger[move capture] @ChatMessage[/TeleportToToken Target2 -1 1]
// The sample will, when a player moves their token over the target token “Target1”,
// delete the players token and recreate it next to the token named Target2
// For the example above the players token will be placed 1 grid unit to the left of Target2 and one grid unit down from Target2

So, If I may, I would love to have a look in-game at what’s wrong.
May I ask you for an invite to your game? Hopefully somewhere private :smiley:

I am not familiar with the macro you posted above so I can’t help much with that one, but I can try my method, and see if something is extremely wrong.

Hi, I am currently struggling to get my previously working Teleport macro working. I just moved to DAE 3.1.0, and My FVTT is 0.7.8. I imported the DAE TeleportToToken macro from the sample macros and have also created a macro TeleportToToken with the following syntax: DynamicEffects.teleportToToken(token, args[0], args[1], args[2])

I have created a folder called Trigger Journal where I have the below updated.

PROBLEM: Whenever a character moves onto the Teleport actor, the new destination scene loads but the character has not moved. Please help! This is very frustrating.

Hey, you have checked off “Execute Macro as GM”. That should be turned off ^^

Also a small reminder that a GM needs to be online for this process to work. To test you would need an incognito browser up at the same time ^^ Hope that helps

Hey Kevin, based in India so not sure if the time zones would work for both of us. The “Execute Macro as GM” is not selected. Here are the fresh screen shots. I have followed your advice but this doesnt still work. DAE - 3.1.0, FVTT - 0.7.8

TeleportToToken Issue2 TeleportToToken Issue3

Do you have all the modules as posted above?

Have Trigger Happy Installed.
Have Furnace Installed.
Have Dynamic effects Installed.
Have a Journal Entry named Trigger Happy .

Hehe… my oh my, how did I miss the comment. I am so sorry.

Hi, I’m trying to use the teleport and traps in my games, but rather than completing the action when a token steps on the triggering actor, the macro will post “/TeleportToToken X” (X being the actor name). What am I doing wrong? The move to another scene works without issue, it’s just movement within the scene.