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

Requesting a Script - "Swap" (changing object from Foreground to Map layer only)

April 10 (3 months ago)
It's like BUMP but instead of manipulating objects between GM and Token Layer, "SWAP" will manipulate objects between Map and Foreground Layer.

So on the fly, someone finished exploring under a bridge but now needs to go over the bridge, I can just do it with a click of a button instead of having to move to correct layer, right click object, move to other layer. It is treated just the same as BUMP does.

Yellow = Foreground Layer
Orange (or transparent if possible) = Map Layer

April 10 (3 months ago)
The Aaron
Roll20 Production Team
API Scripter

I've been thinking about precisely that sort of script. =D

In the interim, you can use the new version of TokenMod to do the swap, though you'll need two macros to handle it (or some MetaScript Magic). Simplistic is to link the graphic to a character and then use something like:

!token-mod --set layer|foreground --ids @{movable|character_id} --current-page


April 10 (3 months ago)
timmaugh
Forum Champion
API Scripter

Yep, can confirm. Once you have the new TM code, you can run something like:

!token-mod --set layer|{&if @(-ONScZYtKsfQ7Sn8CRhx.layer) = foreground}map{&else}foreground{&end} --ids -ONScZYtKsfQ7Sn8CRhx --current-page --ignore-selected

...where the ID represents the token you want to move between layers.

Or, if you had a set of tokens you wanted to move (like a bunch of tree tokens representing a forest canopy and the characters were flying over them instead of walking through them), you could gather all of their IDs and put them all in the --ids argument. You would still have to use the ID version of the Fetch layer check to see what layer that token was on:

@(-ONScZYtKsfQ7Sn8CRhx.layer)

...because we're ignoring the selected tokens for this.

Alternatively, you could put the IDs in a {&select} structure:

{&select -ONScZYtKsfQ7Sn8CRhx, -M1234567890abcdef, -N0987654321fedcba}

...and then use the @(selected...) version of the layer check, dropping the --ids and ignore-selected arguments:

!token-mod --set layer|{&if @(selected.layer) = foreground}map{&else}foreground{&end} --current-page {&select -ONScZYtKsfQ7Sn8CRhx, -M1234567890abcdef, -N0987654321fedcba}

But, as Aaron said, if you have a character to represent the forest (like "Fangorn Forest") and then assign all of your tree tokens to represent that character, you can move the entire forest with a command like:

!token-mod --set layer|{&if @(Fangorn Forest.layer) = foreground}map{&else}foreground{&end} --ids @{Fangorn Forest|character_id} --current-page --ignore-selected

So... lots of options.

April 10 (3 months ago)

I did not understand any of that lol.
all of that sound alien to me. I have to see it to understand. 

April 10 (3 months ago)
timmaugh
Forum Champion
API Scripter

OK... then follow these steps:

1) Create a character called "Fangorn Forest" (you don't need to build the character or enter any information)

2) Drag a tree asset from your gallery onto your map on the Foreground layer

3) Double click it to open the token properties, and set it to represent the Fangorn Forest character, and save the settings.


4) Repeat this process with a different tree asset (if desired), to create a variation in the foliage

5) Copy/paste a few of these trees around, making it appear to be forest-like


6) Go to your token layer, and see how a token interacts with these Foreground-layer assets (to prove the dimming effect and that the trees are on the Foreground layer).

7) Run this command:

!token-mod --set layer|{&if @(Fangorn Forest.layer) = foreground}map{&else}foreground{&end} --ids @{Fangorn Forest|character_id} --current-page --ignore-selected

The trees will now go to the map layer. Note how the token interacts with them, now (on top of them).

This can be handy to depict any... Eagle-flights, let's say, where the characters are far above the forest.

8) Run the SAME command again, and the trees will return to the Foreground layer.

9) Run the SAME command again, and the trees will return to the Map layer.

You have created a toggleable command.

April 10 (3 months ago)
that helps!

so If I have multiple different assets, I need character sheets for them too?
April 10 (3 months ago)
timmaugh
Forum Champion
API Scripter

The sheet represents the group of things you want to flip at the same time... How you group them is really up to you.