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

moving groups of tokens between layers with a button

February 28 (2 years ago)

Not sure if this is something doable, but I am trying to find a way to have a map set up where walls appear and disappear each turn. I have a grid of walls set up in an arena, each section has 4 walls, each turn I roll 2 D4 and the corresponding wall appears if it was hidden or disappears if it was visible. I could do this all manually but would really slow down the encounter, I was hoping it is possible to map the sections to a macro button that I could activate each round and that would move the group of tokens between the map layer and GM layer. Its 23 icons per group (92 total) so automating it would he a huge help. I was looking at Token-Mod but not seeing a way of setting it other then hard coding each separate token ID. Can you set an ID for a group of tokens? are my aspirations just too much for this? 

February 28 (2 years ago)
Andrew R.
Pro
Sheet Author

You could write it in ScriptCards, it can handle the layer changing and being triggered by events. 

March 01 (2 years ago)
Pat
Pro
API Scripter

...if you're using the walls to block actual movement, maybe a combination of secret doors that open and close, plus moving tokens between layers? 

March 01 (2 years ago)
timmaugh
Forum Champion
API Scripter

You can manage it with TokenMod and some metascripts, too. TokenMod will act on the selected token, and you can -- for the purposes and duration of only your command message -- pretend like the affected wall token is selected. In other words, "virtually" select it. That would be SelectManager.

The question is how do you tie your roll to the appropriate token...?

The solution that pops into my head is to catalog them in relation to the section (square) or the grid overall. That would be done in a Mule.

How does your roll of 2d4 relate to your overall set of 92 potential walls to alter? And are you tied to 2d4? What is the mechanic used to select the wall... ie, are there only a certain number of walls that could appear/disappear at any given time based on where the characters were?

March 01 (2 years ago)

The walls are just visual, they don't need to block light, visibility, or movement. 

I didn't need any action to be tied to the die roll. The layout is an open arena with the walls (if all visible) forming a 2x2 grid. the 2 D4 was because I had the walls arranged as a series of crosses, so the 4 segments in each cross would be assigned a number (the map has 23 of these crosses, so 92 total wall segments), roll the number, toggle it as visible/invisible. with 2 sections changing each turn (as a lair action). I just tried a manual test of that and will probably be switching to a D8 roll, with each original 2 grid length walls becoming 1 grid length so 8 moveable parts per cross. 

I'm over reaching a bit on this but it was a concept I had planned from the start of my campaign and would have been a lot easier on a table top (just place/pull sticks to represent the walls. Really hoping I can pull this off, my experience with scripting in Roll20 is basic bordering on rudimentary. 


March 01 (2 years ago)

Edited March 01 (2 years ago)

Are the walls Tokens or Paths(Line Drawings)? 

If they are Paths (Lines, Polylines, Circles, Squares), See the code below in the next post.

If they are Tokens - you need a simple way to group them, probably by token name, something like WallSet1, WallSet2, ....

It would then be easy to Move a group of tokens with the same name between layers with just ScriptCards.

March 01 (2 years ago)

Edited March 01 (2 years ago)

Here's a ScriptCard that does most of what I think you want.  This card will list Paths (lines, polylines, circles, squares), grouping them by color (stroke).  It includes a count of each Path object and a string of characters (o,g,m, and w) indicating what layer the paths are on for that stroke.  It also shows a set of buttons to move all Paths of that stroke to the associated Layer.  It runs against the page the ribbon is on. 

It would be easy to modify to have it run against a page for a selected token.  It would also be easy randomly move Paths between layers, just need the rules.

An interesting idiosyncrasy of Roll20, Paths drawn on the Walls layer are given a RGB color, while Paths drawn on all other layers are given a Hex (#FFFFFF) color.  


Based on the dialog above - there are 6 path objects with the stroke color #F70000 and all of them are on the Object layer.  


!scriptcard  {{

  --/|Script Name : Path Layers
  --/|Version     : 3-1-2023
  --/|Requires SC : 2.2.0+, 
  --/|Author      : Will M.
  --/|Description : Interface for moving groups of paths based on color between layers

  --#title|Paths Layers
  --/|#overridetemplate|dnd
  --#reentrant|PathLayers
  --#timezone|America/Chicago
  --#debug|0

  -->SETUP_GLOBAL_VARS|
  
  --:TOP|

  --#whisper|gm
  --&pid|[*C:playerpageid]

  --~|array;objects:path;aryPaths;
  --~|array;define;aryStrokes

  --/| Build unordered List of Strokes
  --?"[@aryPaths(length)]" -eq "0"|END
  --%loop|foreach;aryPaths
    --?[*O:[&loop]:path:_pageid] -eq [&pid]|[
      --&aryStrokes([@aryStrokes(length)])|[*O:[&loop]:path:stroke]
      --/|+Stroke|[*O:[&loop]:path:stroke] / [*O:[&loop]:path:layer] / 
    --]|
  --%|

  --/| Next - Sort them
  --~|array;sort;aryStrokes

  --&PrevStroke|[@aryStrokes(0)]

  --=StrokeCount|0
  --&StrokeLayers|
  --%loop|foreach;aryStrokes
    --?"[&loop]" -ne "[&PrevStroke]"|[

      -->BUILD_STROKE_COLOR|[&PrevStroke];hexcolor
      -->GET_STROKE_LAYERS|[&PrevStroke];StrokeLayers
      --+|([$StrokeCount.raw]-[&StrokeLayers]) [#[&hexcolor]] [&PrevStroke] [/#] [rbutton]GM::SET_LAYER;[&PrevStroke]\gmlayer[/rbutton] [rbutton]Obj::SET_LAYER;[&PrevStroke]\objects[/rbutton] [rbutton]Map::SET_LAYER;[&PrevStroke]\map[/rbutton] [rbutton]Walls::SET_LAYER;[&PrevStroke]\walls[/rbutton]
      --&PrevStroke|[&loop]
      --=StrokeCount|0
    --]|
    --=StrokeCount|[$StrokeCount] + 1
    --&StrokeLayers|+
  --%|
  -->BUILD_STROKE_COLOR|[&PrevStroke];hexcolor
  -->GET_STROKE_LAYERS|[&PrevStroke];StrokeLayers
  --+|([$StrokeCount.raw]-[&StrokeLayers]) [#[&hexcolor]] [&PrevStroke] [/#] [rbutton]GM::SET_LAYER;[&PrevStroke]\gmlayer[/rbutton] [rbutton]Obj::SET_LAYER;[&PrevStroke]\objects[/rbutton] [rbutton]Map::SET_LAYER;[&PrevStroke]\map[/rbutton] [rbutton]Walls::SET_LAYER;[&PrevStroke]\walls[/rbutton]
  --:END|
--x|

--:BUILD_STROKE_COLOR|Stroke;rtnHexColor
  --&[%2%]|000000
  --?"[%1%]" -inc "rgb"|EXIT_BSC
    --~tmp|string;after;#;[%1%]
    --&[%2%]|[&tmp]
  --:EXIT_BSC|
--<|

--:SET_LAYER|Stroke\Layer
  --#hidecard|0
  --~Arg|string;split;\;[&reentryval]
  --&Stroke|[&Arg1]
  --&Layer|[&Arg2]
  --~|array;objects:path;aryPaths;[&Stroke]
  --%loop|foreach;aryPaths
    --?[*O:[&loop2]:path:_pageid] -ne [&pid]|NEXT_SL
      --!path:[&loop]|layer:[&Layer]
    --:NEXT_SL|
  --%|
  -->TOP|
--x|

--:GET_STROKE_LAYERS|Stroke;rtnLayers
  --&rtnLayers|
  --~|array;objects:path;aryP2;[%1%]
  --%loop2|foreach;aryP2
    --?[*O:[&loop2]:path:_pageid] -ne [&pid]|NEXT_GSL
      --~s|string;left;1;[*O:[&loop2]:path:layer]
      --&rtnLayers|+[&s]
    --:NEXT_GSL|
  --%|
  --&[%2%]|[&rtnLayers]
--<|

--:OUTPUT_PATH_INFO| (for debugging)
  --#title|[&reentryval]
  --#hidecard|0
  --~DT|system;date;getdatetime
  --+id|[*O:[&reentryval]:path:_id]
  --+type|[*O:[&reentryval]:path:_type]
  --+pageid|[*O:[&reentryval]:path:_pageid]
  --+path|[*O:[&reentryval]:path:_path]
  --+fill|[*O:[&reentryval]:path:fill]
  --+stroke|[*O:[&reentryval]:path:stroke]
  --+stroke_width|[*O:[&reentryval]:path:stroke_width]
  --+rotation|[*O:[&reentryval]:path:rotation]
  --+layer|[*O:[&reentryval]:path:layer]
  --+width|[*O:[&reentryval]:path:width]
  --+height|[*O:[&reentryval]:path:height]
  --+top|[*O:[&reentryval]:path:top]
  --+left|[*O:[&reentryval]:path:left]
  --+scaleX|[*O:[&reentryval]:path:scaleX]
  --+scaleY|[*O:[&reentryval]:path:scaleY]
  --+barrierType|[*O:[&reentryval]:path:barrierType]
  --+oneWayReversed|[*O:[&reentryval]:path:oneWayReversed]
  --+controlledby|[*O:[&reentryval]:path:controlledby]
  --vpoint|[*O:[&reentryval]:path:left] [*O:[&reentryval]:path:top] ping 
--x|

--:SETUP_GLOBAL_VARS|
  --&QB|? --&QB|+{ --&QE|}
  --&AB|@ --&AB|+{
  --&TB|& --&TB|+# --&TB|+64 --&TB|+; --&TB|+{
  --&BED|& --&BED|+# --&BED|+128719;
  --&CLOCK|& --&CLOCK|+# --&CLOCK|+128336;
  --&SPACE|X X --&SPACE|[&SPACE(1,1)]
  --&spc|&nbsp;
  --&obrac|[ --&cbrac|]
  --&vbar||  
  --&DASH|-
  --&DDASH|[&DASH][&DASH]
--<|

}}


March 01 (2 years ago)
timmaugh
Forum Champion
API Scripter

Ok... What I am trying to establish is how you would get from either 2d4 or 1d8 (either 7 or 8 potential outcomes) to which of the 92 individual tokens you would want to manipulate. It seems obvious that there has to be another "bit" of information ... which maybe you are currently handling intuitively (ie, "the closest cross formation to the token"). That's what I meant by the "mechanic" you're working with... what is it that tells you, from the 92 component pieces of the various crosses, you are working with these 8 (this cross) against which to evaluate your roll?

If your roll could be *ANY* of the crosses... ie, you roll and you could be altering ANY component of ANY cross... and if each cross were made up of 8 component parts... you could name each token. The eight component tokens of the first cross formation would be:

  • Cross1_1
  • Cross1_2
  • Cross1_3
  • Cross1_4
  • Cross1_5
  • Cross1_6
  • Cross1_7
  • Cross1_8

You'd have 23 groups like this, you say (Cross1, Cross2, etc.).

To arrive at *ANY* of these individual tokens, you can roll 1d23 and 1d8, and use ZeroFrame to extract the roll value INTO the name:

Cross[[1d23]].value_[[1d8]].value

That will give you the name of just ONE of your tokens. Then you use that inside a SelectManager formation to virtually select the token:

{&select Cross[[1d23]].value_[[1d8]].value }

Finally, you pop that into a TokenMod command line designed to move selected tokens to the GM layer:

!token-mod --set layer|gmlayer {&select Cross[[1d23]].value_[[1d8]].value }

Great. Except we also want to be able to toggle it back and forth between the gmlayer layer and the objects layer. Well, we can read the layer of the token using Fetch:

@(selected.layer)

And we can use that in an APILogic conditional to return the opposite layer:

{&if @(selected.layer) = objects}gmlayer{&else}objects{&end}

Final Version

Then we just put that in the same TokenMod command line, and we have a veritable toggle macro for any of your 92 parts:

!token-mod --set layer|{&if @(selected.layer) = objects}gmlayer{&else}objects{&end} {&select Cross[[1d23]].value_[[1d8]].value }

Again, this assumes that your roll could affect ANY of the 92 wall pieces on the board (and that they're tokens). If that isn't the case and there is a more finite set of walls which could activate on any 1d8 check... I have to ask again: what is the game mechanic that lets you narrow the set and to tie your 1d8 to particular walls in the set of 92?


REQUIRED SCRIPTS:

TokenMod, ZeroFrame, APILogic, Fetch, SelectManager

March 01 (2 years ago)


Will M. said:

Are the walls Tokens or Paths(Line Drawings)? 

They are wall tokens.


March 01 (2 years ago)


timmaugh said:

Ok... What I am trying to establish is how you would get from either 2d4 or 1d8 (either 7 or 8 potential outcomes) to which of the 92 individual tokens you would want to manipulate. 

the map has a series of crosses that are 2 segements in each direction. I'd assign a number (1-8) for each segment, each cross would have identical numbering. 

the die roll will define which segment appears or disappears each turn, so the landscape is constantly changing. so all the #1 segments are a single group, #2 segments are another group etc. so each die roll effects all the crosses at the same time. so what I was hoping is to have some way of assigning some kind of ID for each of the 8 groups so I could toggle them visible (on the map layer) and invisible (on the GM Layer) without having to manually change to the layers to move them each time. 

March 01 (2 years ago)

the full layout (if all segments were visible) would look like this...


March 01 (2 years ago)

Edited March 01 (2 years ago)

I think there's a much simpler way of doing this. (Untested, but this should work.)

1. Create a rollable token with two sides: one side that is an individual wall segment, and the other side that is an invisible .png token.

2. Create 8 characters named Wall1, Wall2, etc.

3. Use the rollable token as the default token for each of those eight characters.

4. On each 'Wall' character sheet, create an Ability with this TokenMod command (and set it as a TokenAction):

!token-mod --ids @{selected|character_id} --set currentside|+

5. Then place one group of Wall1, Wall2, Wall3, etc. in their correct orientation.  Select the whole group and copy and paste it in all of the other location it needs to be in. 

6. Then when you are running the game, you would select a single wall (e.g. Wall1), and use the Ability TokenMod command, and it should swap all of the Wall1 tokens to the next side.

March 01 (2 years ago)


Tim L. said:

I have a grid of walls set up in an arena, each section has 4 walls, each turn I roll 2 D4 and the corresponding wall appears if it was hidden or disappears if it was visible.

the map has a series of crosses that are 2 segements in each direction. I'd assign a number (1-8) for each segment, each cross would have identical numbering. 

the die roll will define which segment appears or disappears each turn, so the landscape is constantly changing. so all the #1 segments are a single group, #2 segments are another group etc. so each die roll effects all the crosses at the same time. 

I'm a little confused on the mechanics though. It seems like you should be rolling a 1d8, not 2d4?

March 01 (2 years ago)
timmaugh
Forum Champion
API Scripter


Tim L. said:


 all the #1 segments are a single group, #2 segments are another group etc. so each die roll effects all the crosses at the same time. so what I was hoping is to have some way of assigning some kind of ID for each of the 8 groups so I could toggle them visible (on the map layer) and invisible (on the GM Layer) without having to manually change to the layers to move them each time. 


OK, that makes sense... and it would change my approach slightly. With 8 sets of tokens that should respond to your die roll, I would establish groups in {&select...} statements and store those in attributes or abilities on a mule character. This is the equivalent of declaring an id to represent a group. Here is how you would make that work:

Let's say that you create a mule character named "WallMule" (if you have a mule/utility character already, just replace references to WallMule with the name of your character), and let's say that I stored all of the group 1 walls in an ability named "Group1", all the group 2 in "Group2", etc. You can either store names (if you want to name the tokens) or IDs if you can quickly collect the token ids (and I have a method for that, below). The ability "Group1" would look like:

{&select -NAzMiu9k9PrK5-B6PP7, -MYzJr9QFmRZPjMgefGS, -MYoq2OAm_g3hM6r-OBa, ...etc.... }

...where those are the token ids of the Group 1 tokens.

Then you can use Fetch & ZeroFrame to return the 1d8th choice from the 8 abilities on WallMule:

%(WallMule.Group[[1d8]].value)

...which will actually return command line syntax that SelectManager will use to select those tokens prior to TokenMod getting the message and taking an action. (Peeking beneath the meta-hood, because SelectManager will only be able to "virtually" select the tokens after the Fetch construction resolves, and since the conditional and the Fetch construction returning the layer from the selected token RELY on there being a selected token, we'll slow those down with a ZeroFrame deferral to make them wait one cycle of the metascripts.)

New End Result Command Line

The end result command line you would send would look more like:

!token-mod --set layer|{\&if @\(selected.layer) = objects}gmlayer{\&else}objects{\&end} %(WallMule.Group[[1d8]].value)

So then the trick is just to either name all of the wall tokens and create the {&select ...} statements, or to gather their IDs and use those to create the {&select ... } statements.

Quick Way to Collect IDs

If you want a quick way to collect IDs and you have SelectManager & ZeroFrame installed, you can select all of your Group 1 walls and then run this command:

!forselected(^) @^(selected.token_id){^&simple}

Copy those IDs from the chat and turn them into a comma-delimited list in the {&select ...} statement in your Group1 ability. Then you can select all of your Group 2 walls and do the same thing, etc.

March 01 (2 years ago)


Jarren said:

I'm a little confused on the mechanics though. It seems like you should be rolling a 1d8, not 2d4?

Yeah, I was testing it out last night and did not like how just having 4 segments was playing out in creating obstacles so I increased it to 8 segments, I'd use 2D8 to determining the toggling segments.

I might have over described my use case and that is causing confusion. 

the basic need is I have 8 groups of tokens and I would like to easily toggle them between the map layer and the GM layer. 

I just yesterday discovered the existence of rollable tokens, and the option would probably be a good fit for this, but not I am just using a web asset for the wall and have even less experience in making tokens then I do in using Roll20 scripts :-). It's definitely something I want to look into but if I can do this without making my own token that would be better. 


March 01 (2 years ago)

Edited March 01 (2 years ago)


timmaugh said:

New End Result Command Line

The end result command line you would send would look more like:

!token-mod --set layer|{\&if @\(selected.layer) = objects}gmlayer{\&else}objects{\&end} %(WallMule.Group[[1d8]].value)

So then the trick is just to either name all of the wall tokens and create the {&select ...} statements, or to gather their IDs and use those to create the {&select ... } statements.

How would I do this with out tying it to the die roll. I can handle the die roll separately and there will be cases when I need to make an alternate roll (rolling the same number on both rolls would cause a segment to toggle twice, something I don't want in this case, so I plan on having a tie breaker roll in those cases, so I am happy manually defining the group. 

March 01 (2 years ago)

Tim L. said:

the basic need is I have 8 groups of tokens and I would like to easily toggle them between the map layer and the GM layer. 


I just yesterday discovered the existence of rollable tokens, and the option would probably be a good fit for this, but not I am just using a web asset for the wall and have even less experience in making tokens then I do in using Roll20 scripts :-). It's definitely something I want to look into but if I can do this without making my own token that would be better. 

I'm pretty sure what I described above will be a simple approach to do exactly what you are looking for.

'Creating' a rollable token doesn't mean to design or draw anything. You create a Roll Table with two items that have images.  The first item is a wall segment (which it sounds like you already have).  The second item is an invisible .png (which you can find online easily) or I've posted one here (click on what looks like empty space between these paragraphs): 

 

If you're worried about the sizing of the items that can be done pretty easily as well with any photo editor, or within Roll20 if you simply set the image to 'Is Drawing'.

March 01 (2 years ago)
timmaugh
Forum Champion
API Scripter


Tim L. said:


How would I do this with out tying it to the die roll. I can handle the die roll separately and there will be cases when I need to make an alternate roll (rolling the same number on both rolls would cause a segment to toggle twice, something I don't want in this case, so I plan on having a tie breaker roll in those cases, so I am happy manually defining the group. 

Let's try this setup...
On my WallMule character, I have created a series of 8 abilities, named Group1, Group2, etc. In those, I have the token ids I want to operate on as a part of that group:

Then I created an ability named WallActionBase, and I put in the command line:

!token-mod --set layer|{\&if @\(selected.layer) = objects}gmlayer{\&else}objects{\&end}

Then I created 8 abilities named MapAction1, MapAction2, etc. These reference the MapActionsBase ability and the Group abilities:

Then I created a menu that would present me with 3 rolls which I could choose to apply, a button to reroll, and a button to instead choose a group. I called this ability MapActionMenu:

!/w gm &{template:default}{{name=Maze Adjustment}}{{Roll 1=[[1d8cs9cf0]] [Apply](~WallMule|MapAction$[[0]].value)}}{{Roll 2=[[1d8cs9cf0]] [Apply](~WallMule|MapAction$[[1]].value)}}{{Roll 3=[[1d8cs9cf0]] [Apply](~WallMule|MapAction$[[2]].value)}}{{=[ReRoll](~WallMule|MapActionMenu) [Choose](~WallMule|MapActionChoose)}}{&simple}

Here's what the menu looks like:

And here is a short video of it working (all of my groups were made up of the same four tokens so I could easily toggle them back and forth, no matter what I rolled/chose):

https://screenrec.com/share/BCsrXIQ28O


March 02 (2 years ago)

Edited March 02 (2 years ago)

Step 1:  Give each of the groups of tokens the same name that you want to move between layers together. Walls1, Walls2, ...

Step 2: Write a scriptcard that Loops through all tokens that start with the name Wall, and provides a list of your walls and an associated hide/show button.  (Simple)

Step 3:  Within the same scriptcard (Write a routine to move between layers when you click on the show/hide button (simple).).

Step 4a:  Optional.  Include a button to roll a random D8, and toggle the layer for the token.

Step 4b:  Completely Random Maze - Optional.  Have a button/macro that will Roll a D8 for each Wall token and make it visible/invisible based on the roll.  (very easy). 


March 02 (2 years ago)


Will M. said:

Step 1:  Give each of the groups of tokens the same name that you want to move between layers together. Walls1, Walls2, ...

hopefully this is not a dumb question.. how do you name token groups?




March 02 (2 years ago)

Edited March 03 (2 years ago)


Jarren said:


I'm pretty sure what I described above will be a simple approach to do exactly what you are looking for.

'Creating' a rollable token doesn't mean to design or draw anything. You create a Roll Table with two items that have images.  The first item is a wall segment (which it sounds like you already have).  The second item is an invisible .png (which you can find online easily) or I've posted one here (click on what looks like empty space between these paragraphs): 

OK, thats a little embarrassing.. thought it had to be a specially formatted token 

I'll look into it. As far as the sizing comment, is that something I should be worried about or since it will be on the map layer it would not become an issue? I may not use it here, but this already gave me ideas for a future encounter. 

March 02 (2 years ago)


timmaugh said:

OK, that makes sense... and it would change my approach slightly. With 8 sets of tokens that should respond to your die roll, I would establish groups in {&select...} statements and store those in attributes or abilities on a mule character. This is the equivalent of declaring an id to represent a group. Here is how you would make that work:

Let's say that you create a mule character named "WallMule" (if you have a mule/utility character already, just replace references to WallMule with the name of your character), and let's say that I stored all of the group 1 walls in an ability named "Group1", all the group 2 in "Group2", etc. You can either store names (if you want to name the tokens) or IDs if you can quickly collect the token ids (and I have a method for that, below). The ability "Group1" would look like:

New End Result Command Line

The end result command line you would send would look more like:

!token-mod --set layer|{\&if @\(selected.layer) = objects}gmlayer{\&else}objects{\&end} %(WallMule.Group[[1d8]].value)

So then the trick is just to either name all of the wall tokens and create the {&select ...} statements, or to gather their IDs and use those to create the {&select ... } statements.

Quick Way to Collect IDs

If you want a quick way to collect IDs and you have SelectManager & ZeroFrame installed, you can select all of your Group 1 walls and then run this command:

!forselected(^) @^(selected.token_id){^&simple}

Copy those IDs from the chat and turn them into a comma-delimited list in the {&select ...} statement in your Group1 ability. Then you can select all of your Group 2 walls and do the same thing, etc.


So I do not have any mules set up, this is the first I've heard of this. I am assuming is is done in muler? 

trying to get a handle on what I need installed to make this work. 
you mentioned SelectManager and ZeroFrame, and I assume Muler, looking these up looks like what I need to install is the Meta-Toolbox, is that correct? Anything else (I already have Token-Mod installed but haven't really used it yet)? 

hope I'm not asking too many dumb questions, I appreciate all the input so far (from you and everyone else)!

March 02 (2 years ago)
timmaugh
Forum Champion
API Scripter

You don't actually need Muler... In this case I'm using a "mule" character in the classic sense: a character who can be a mule for some macros (abilities) you want to write and preserve. This lets you port them between games more easily, and it sidesteps the annoying quirk Collection Tab macros have of having HTML entities revert if you open the macro to edit it after you save it.

So, in this case, you don't need Muler... just a character on which you can create the abilities.

The full set of scripts you would need would be:

  • TokenMod
  • APILogic
  • ZeroFrame
  • SelectManager
  • Fetch

After that, just follow the steps and create the character + abilities I mentioned.

March 02 (2 years ago)

So then the trick is just to either name all of the wall tokens and create the {&select ...} statements, or to gather their IDs and use those to create the {&select ... } statements.

Quick Way to Collect IDs

If you want a quick way to collect IDs and you have SelectManager & ZeroFrame installed, you can select all of your Group 1 walls and then run this command:

!forselected(^) @^(selected.token_id){^&simple}

Copy those IDs from the chat and turn them into a comma-delimited list in the {&select ...} statement in your Group1 ability. Then you can select all of your Group 2 walls and do the same thing, etc.

So I've collected the IDs for each group, but these are big lists each, how would I just assign a name to each group as a shorter statement (if possible)? 
March 02 (2 years ago)
timmaugh
Forum Champion
API Scripter

That's what your Group1, Group2, Group3 abilities will do for you:

Create and/or designate the character that will hold the Group1 ability

Create a new ability and name it "Group1"

Take the IDs of the tokens that should be in Group1 and turn them into a comma-delimited list

In the "action" for the ability, enter:

{&select id1,id2,id3,...idn}

...where your list replaces id1,id2,id3,...idn

Now you can refer to %{WallMule|Group1} in a command line, and the {&select...} syntax will be returned, including the appropriate tokens.

March 02 (2 years ago)

Tim L. said:

I'll look into it. As far as the sizing comment, is that something I should be worried about or since it will be on the map layer it would not become an issue? I may not use it here, but this already gave me ideas for a future encounter. 

I just wasn't sure how large of an image you were using for the wall segment -- if it was a large rectangular image or a small image that doesn't neatly fill a 70x70px grid space versus a 70x70px token that would neatly snap into place on the grid.

Once the Rollable Token is created and placed onto the VTT, it should retain it's dimensions even when switching sides (so the invisible .png image can be whatever dimensions and it'll just stretch to fill the space), so you'd just have to make sure the wall segment was the correct size/dimension and then copy it a bunch of times and save it as the default token for the 8 character sheets, then copy the group of 8 wall images wherever you need them duplicated.

March 03 (2 years ago)


timmaugh said:

!token-mod --set layer|{\&if @\(selected.layer) = objects}gmlayer{\&else}objects{\&end}

Looks like this might toggle between GM and the token layers is that correct? 

if I wanted to make this toggle between the Map and GM layers, would this be the correct syntax?

!token-mod --set layer|{\&if @\(selected.layer) = map}gmlayer{\&else}map{\&end}



March 03 (2 years ago)
timmaugh
Forum Champion
API Scripter

Yes, exactly.

March 03 (2 years ago)

Edited March 03 (2 years ago)

I think I missed something..

I created my WallMule character

I created the 8 groups (Group1...Group8) abilities with the token IDs for each group set. 

I created the MapActionBase Ability

and created the 8 MapAction abilities (MapAction1...MapAction8)

and created the MapActionMenu ability and added to the macro bar.

I have the MapActionMenu button  

I get the 3 die rolls and the optioins to apply and re-roll and choose. but when I apply, nothing happens on my map.

the reroll does reroll, but when I select the choose button I get an error "No ability was found for %{WallMule|MapActionChoose}" and that seems to make sense because I haven't set up an ability for that (did not see that in your post). however I am not having the groups appear or dissapear. I tried switching back to the original code for MapActionBase that you had posted but no change, I feel that I am very close but I've messed up some step somewhere and don't understand it enough to troubleshoot. 

March 03 (2 years ago)
timmaugh
Forum Champion
API Scripter

OK, sorry... here is the MapActionChoose ability:

!%{WallMule|MapActionBase} %(WallMule.Group?{Select wall group|Group 1,1|Group 2,2|Group 3,3|Group 4,4|Group 5,5|Group 6,6|Group 7,7|Group 8,8})

As for why nothing is happening, make sure you have all of these scripts installed:

  • TokenMod
  • APILogic
  • ZeroFrame
  • SelectManager
  • Fetch

If you do and you still can't get it work, post one example of your Group and MapAction abilities so I can see how you set them up.

If I can't spot the problem, you can invite me and I'll help get it setup.

March 03 (2 years ago)

So good news and bad news...

good news is I discovered my flaw. I did have the correct scrips installed. however I had created the group statments with 

(&select <comma delineated IDs>)

instead of 

{&select <comma delineated IDs>}

old eyes... 


so now I can make the walls move from the DM layer to the Map layer, however they do not move back the the GM layer if the group is selected again.

this is the MapActionBase code

!token-mod --set layer|{\&if @\(selected.layer) = map}gmlayer{\&else}map{\&end}

I tested reverting the code to what you had posted that moved betwen GM and Token Layer and it works as advertised

!token-mod --set layer|{\&if @\(selected.layer) = objects}gmlayer{\&else}objects{\&end}
March 03 (2 years ago)
timmaugh
Forum Champion
API Scripter

Interesting... I'll have a look at that. I'm not sure if that is a limitation I imposed on SelectManager (to not select things on the map layer) or if that is a limit placed by Roll20. If it's me, I can try to lift that.

(Yours is the first use case I've come across where people want to select something on the map layer!)

March 03 (2 years ago)
timmaugh
Forum Champion
API Scripter

OK... yeah, it was me. I'd put a limiter on that. I updated the code and released it to my github repo, as well as slotted it in for the 1-click merge next week. Once you have the updated code, you can go back to swapping between the map and gm layers.

March 03 (2 years ago)

How long does that take? (does it auto update?) 

thanks for all your help on this

March 03 (2 years ago)
timmaugh
Forum Champion
API Scripter

If you got the script from the one-click (on your Script's page for your game, picking a font from the list), then it will automatically update if there is any change. Typically the merges happen on... Tuesday nights... I think...?

If you need it prior to that, you can grab the code from my repo link (previous message) and manually install it... but then you might want to go back to the one-click version once you know you're past the point where the one-click has caught up. Just in case there are any bug-fixes or feature adds down the line.

March 03 (2 years ago)

Cool, that should be good, game isn't for another week.

March 09 (2 years ago)

FYI, this is now working with swapping between the GM layer and the Map layer. Perfect! 

Thank you so much

March 09 (2 years ago)
timmaugh
Forum Champion
API Scripter

Excellent! Glad it worked for you!