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

Marching Order v3.0

March 29 (4 years ago)

Edited April 07 (4 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter

Gosh-dang, it's been a while since I've updated any my scripts, hasn't it? 

I've got a brand new update for the Marching Order script which I'm sure ya'll are going to enjoy. For those unfamiliar, the Marching Order script lets you establish a marching order for a group of tokens to follow behind their leader.

What's changed?

Before, the Marching Order script just moved tokens following each other to the next waypoint in the movement whenever the leader moved. Now, everything operates by seamless marching order formations. 

Everyone stays grouped together into smooth, arbitrary marching formations. These formations need not necessarily be in a single file line. That's right! Now tokens can form marching formations side-by-side, further to the back, a little bit ahead, or anywhere else relative to the leader of the formation. Wherever the leader moves, the rest of the tokens will follow along in that formation. It even works with moving diagonally and around corners (and diagonally around corners).

Check out this new demo gif!


The Script

The script is now available through the One-Click API library.

Dependencies

The Marching Order script now depends on the Vector Math and Token Collision scripts. Please make sure these scripts are installed before trying to use the new version of this script.

The Docs

See the copy-pasta'ed docs below:


3.1 Updates

* Added button for creating ad-hoc formations that aren't saved.
* Added button for making one token follow another at some set distance as an ad-hoc formation.
* Reorganized the menu a little bit.
* Formations will only look for their tokens on the objects layer when they are applied.

v3.0 Updates
* The script has been reworked entirely. Marching orders now work based upon formations formed when you tell a group of tokens to follow a leader.
* You can now save multiple formations and load them up to be used later.

This script allows you to select tokens and tell them to follow each other
in some specified marching formation. Marching orders are defined by formations,
where there is a leader token and one or more follower tokens. When you set
tokens to follow a leader, it will record their position relative to the
leader in that formation, and they'll maintain that position as the leader
moves. This formation is maintained even when the leader travels around corners.

Chat Menu

When the script is installed, it will create a macro called
'MarchingOrderMenu'. This macro will display a menu in the chat that provides
the user interface for the script.

Below is documentation for each of the menu items:

Ad-Hoc Formations

The following menu items allow you to create one-time-use marching formations.

Ad-Hoc Formations -> Follow

This button allows you to have a token simply follow behind another.

First, select the token that you want to be the follower, then click the Follow
button. Next, click the token you want them to follow. Then in the prompt that
appears, enter how far behind you want them to follow (leave as 0 to follow
directly behind them).

Be advised of the following gotchas:
* A token can't follow behind another if the other token already has followers.

Ad-Hoc Formations -> Ad-Hoc Formation

To form a one-time-use formation, use this button.

To create a new marching order formation, select a group of tokens, with one
of them having either the black-flag or flying-flag status marker active. That
token will be the leader of the formation. (See Moving in Formation below)

Then click the Ad-Hoc Formation button in the chat menu. It will ask you to enter
which direction the formation is facing at the time you've created it.
This marching formation will be applied to the selected tokens.

Be advised of the following gotchas:
* You must have one of the selected tokens have either the 'black-flag' or 'flying flag' status marker. This is used to designate the leader of the formation.

Saved Formations

Under this section of the chat menu, you can view the formations you have
previously created. The formations each displayed in a boxed area with their name,
a preview of the formation, and some buttons to either use the formation or
delete it. The previews display the marching orders proceeding westward.

Saved Formations - > New formation

This button allows you to create a formation and save it for future use.

To create a new marching order formation, select a group of tokens, with one
of them having either the black-flag or flying-flag status marker active. That
token will be the leader of the formation. (See Moving in Formation below)

Then click the New Formation button in the chat menu. It will ask you to enter
which direction the formation is facing at the time you've created it, and it
will ask you to give a name for the new formation. This marching formation will
be applied to the selected tokens and it will also be saved for future use
(See Saved Formations).

Be advised of the following gotchas:
* You must have one of the selected tokens have either the 'black-flag' or 'flying flag' status marker. This is used to designate the leader of the formation.
* Each new formation must have a unique name.

Saved Formations -> Use

Click this button to use the previously saved marching formation. It will be
applied to the relevant tokens on the page that currently has the
players ribbon.

Be advised of the following gotchas:
* All of the tokens in the formation must be on the current page. If a token is missing, the script will yell at you for it, but the rest of the tokens will be allowed to move in formation.
* There can't be duplicates of any tokens in the formation on the current page.

Saved Formations -> Delete

Click this button to delete the previously saved marching formation.

Other Actions

Other Actions -> Stop Following

To stop all the active marching formations, click the Stop All Following button
in the chat menu.

Other Actions -> Clear Script State

If you'd like to start afresh with a whole blank state for the Marching Order
script, you can click the Clear Script State button to reset the script
to its factory settings.

Moving in Formation

When a marching formation is applied, all the tokens relevant to the formation
will begin following their leader in that formation. When the leader moves,
the other tokens in the formation will move along with them, according to
their position in the formation.

Stepping out of Formation

You can remove a token from an active formation at any time by just moving it
manually. That token will no longer move along with the other tokens in that
formation.




Omg my players were just talking about how they wish the Marching Order script worked like this! Looks fantastic, I can't wait to try it out!


Stephen L. said:

Gosh-dang, it's been a while since I've updated any my scripts, hasn't it? 

I've got a brand new update for the Marching Order script which I'm sure ya'll are going to enjoy. For those unfamiliar, the Marching Order script lets you establish a marching order for a group of tokens to follow behind their leader.

What's changed?

Before, the Marching Order script just moved tokens following each other to the next waypoint in the movement whenever the leader moved. Now, everything operates by seamless marching order formations. 

Everyone stays grouped together into smooth, arbitrary marching formations. These formations need not necessarily be in a single file line. That's right! Now tokens can form marching formations side-by-side, further to the back, a little bit ahead, or anywhere else relative to the leader of the formation. Wherever the leader moves, the rest of the tokens will follow along in that formation. It even works with moving diagonally and around corners (and diagonally around corners).

Check out this new demo gif!


The Script

The new version of the script should be available through the One-Click API Library soonish. Until then, you can manually get it here: 

https://github.com/Cazra/roll20-api-scripts/blob/march/MarchingOrder/3.0/marchingOrder.js

Be advised that the script now requires the Vector Math script.

The Docs

See the copy-pasta'ed docs below:



v3.0 Updates

  • The script has been reworked entirely. Marching orders now work based upon formations formed when you tell a group of tokens to follow a leader.
  • You can now save multiple formations and load them up to be used later.

This script allows you to select tokens and tell them to follow each other in some specified marching formation. Marching orders are defined by formations, where there is a leader token and one or more follower tokens. When you set tokens to follow a leader, it will record their position relative to the leader in that formation, and they'll maintain that position as the leader moves. This formation is maintained even when the leader travels around corners.

Chat Menu

When the script is installed, it will create a macro called 'MarchingOrderMenu'. This macro will display a menu in the chat that provides the user interface for the script.

New formation

To create a new marching order formation, select a group of tokens, with one of them having either the black-flag or flying-flag status marker active. That token will be the leader of the formation. (See Moving in Formation below)

Then click the New Formation button the chat menu. It will ask you to enter which direction the formation is facing at the time you've created it, and it will ask you to give a name for the new formation. This marching formation will be applied to the selected tokens and it will also be saved for future use (See Saved Formations).

Be advised of the following gotchas:

  • You must have one of the selected tokens have either the 'black-flag' or 'flying flag' status marker. This is used to designate the leader of the formation.
  • Each new formation must have a unique name.

Stop Following

To stop all the active marching formations, click the Stop All Following button in the chat menu.

Saved Formations

Under this section of the chat menu, you can view the formations you have previously created. The formations each displayed in a boxed area with their name, a preview of the formation, and some buttons to either use the formation or delete it. The previews display the marching orders proceeding westward.

Saved Formations -> Use

Click this button to use the previously saved marching formation. It will be applied to the relevant tokens on the page that currently has the players ribbon.

Be advised of the following gotchas:

  • All of the tokens in the formation must be on the current page. If a token is missing, the script will yell at you for it, but the rest of the tokens will be allowed to move in formation.
  • There can't be duplicates of any tokens in the formation on the current page.

Saved Formations -> Delete

Click this button to delete the previously saved marching formation.

Clear Script State

If you'd like to start afresh with a whole blank state for the Marching Order script, you can click the Clear Script State button to reset the script to its factory settings.

Moving in Formation

When a marching formation is applied, all the tokens relevant to the formation will begin following their leader in that formation. When the leader moves, the other tokens in the formation will move along with them, according to their position in the formation.

Stepping out of Formation

You can remove a token from an active formation at any time by just moving it manually. That token will no longer move along with the other tokens in that formation.





Super pumped for this!

March 29 (4 years ago)
Ravenknight
KS Backer

Sounds great! My players have asked for this feature on multiple occasions. :)

How will it work with dynamic lightning? Could the script "push" a token outside of the set lines if we use a broad formation?

March 29 (4 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter


Ravenknight said:

Sounds great! My players have asked for this feature on multiple occasions. :)

How will it work with dynamic lightning? Could the script "push" a token outside of the set lines if we use a broad formation?


Yes, tokens could potentially be pushed outside the dynamic lighting walls if they're in a broad formation. I might need to look into a way to avoid that.

March 30 (4 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter

Added a note about new dependencies. The Marching Order script depends on the Vector Math script now.

March 30 (4 years ago)

Edited March 30 (4 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter

Update:

The script now handles collisions between broad formations and dynamic lighting walls. Check out this preview demonstrating it:

On a side note, the script now also requires the Token Collisions script.

March 30 (4 years ago)
Ravenknight
KS Backer

That's amazing Stephen! Thank you so very much for this and all your other amazing scripts!

March 30 (4 years ago)
vÍnce
Pro
Sheet Author

I don't even need players now. ;-P

Awesome job!

Brilliant, this is so fun to use! Is it possible to prevent player tokens from overlapping each other when in marching order? It happens sometimes when a broad formation goes around corners. See GIF below


March 30 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

You're moving with the arrows keys, right?  that last move back around the corner was ← ← ← ↓ ↓ ?  Looks like it only responded to the first key press.

March 30 (4 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter


Persephone said:

Brilliant, this is so fun to use! Is it possible to prevent player tokens from overlapping each other when in marching order? It happens sometimes when a broad formation goes around corners. See GIF below


Big maybe. I considered also including the other tokens in the formation in the collision detection, but wasn't sure if in some edge cases it might force tokens into the walls.

I might fiddle around with it to see if it's feasible, but I figure it's better to deal with tokens overlapping each other than getting pushed inside walls.


@The Aaron, yeah I'm using keys in the example. I feel like overall it works more smoothly with dragging the tokens, but half my players use arrows to move so I've been testing both methods.

@Stephen, I agree! It's a minor thing, so I don't mind it being left alone if fixing it breaks other features.

March 31 (4 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

That's pretty snazzy. You could even make the leader a party token they could take turns moving.

March 31 (4 years ago)
Ravenknight
KS Backer

It works great but I kinda miss the ability to just follow another character without any other fancy stuff. Can this still be used or is it formations only from now on?

@Ravenknight, I think just saving a single-file line formation should give you the effect you looking for?

The main difference is it will try to keep all tokens in a line in the order they start out,, instead of moving each token to the last position of the one before it.

March 31 (4 years ago)

Edited March 31 (4 years ago)
Ravenknight
KS Backer


Persephone said:

@Ravenknight, I think just saving a single-file line formation should give you the effect you looking for?

If everybody are moving at once yea, but sometimes my players like to move around the map on their own with only one friend, an NPC or familiar as company. Having a quick button to add them to follow the character in question is a great benefit for me and the way we usually used Marching Order in the past. But considering how easy it is to create new formations it´s not a big thing. Just wondering if it can still be done.


Oh that's a good point. Also makes me wonder if multiple formations can function at once, for multiple groups moving to different locations...

March 31 (4 years ago)

Edited March 31 (4 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter


Ravenknight said:


Persephone said:

@Ravenknight, I think just saving a single-file line formation should give you the effect you looking for?

If everybody are moving at once yea, but sometimes my players like to move around the map on their own with only one friend, an NPC or familiar as company. Having a quick button to add them to follow the character in question is a great benefit for me and the way we usually used Marching Order in the past. But considering how easy it is to create new formations it´s not a big thing. Just wondering if it can still be done.


I suppose that would still be useful to have an ad-hoc follow button for just simple old-style single-file formations that aren't saved. For the time being, it's formations only.


Persephone said:

Oh that's a good point. Also makes me wonder if multiple formations can function at once, for multiple groups moving to different locations...


Yes, you can have multiple formation groups at once. 


March 31 (4 years ago)

Edited March 31 (4 years ago)

I'm getting this error in the chat log for some reason, only one token is following the leader, but it happens any time the leader moves, even if I remove any followers

"TypeError: Cannot read property '0' of undefined\n    at _.chain.map.seg (apiscript.js:24346:11)\n    at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:205:24)\n    at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1639:39)\n    at _testCirclePolyCollision_clipSegments (apiscript.js:24341:6)\n    at _testCirclePolyCollision (apiscript.js:24328:20)\n    at _testCirclePathCollision (apiscript.js:24278:12)\n    at _testCollision (apiscript.js:24501:12)\n    at _.chain.map.other (apiscript.js:24057:18)\n    at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:205:24)\n    at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1639:39)"
April 01 (4 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter


Persephone said:

I'm getting this error in the chat log for some reason, only one token is following the leader, but it happens any time the leader moves, even if I remove any followers

"TypeError: Cannot read property '0' of undefined\n    at _.chain.map.seg (apiscript.js:24346:11)\n    at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:205:24)\n    at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1639:39)\n    at _testCirclePolyCollision_clipSegments (apiscript.js:24341:6)\n    at _testCirclePolyCollision (apiscript.js:24328:20)\n    at _testCirclePathCollision (apiscript.js:24278:12)\n    at _testCollision (apiscript.js:24501:12)\n    at _.chain.map.other (apiscript.js:24057:18)\n    at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:205:24)\n    at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1639:39)"


Thanks, the stack trace helps. I'll look into it.

I should also clarify that the formation consisted of 4 tokens, but only 1 would follow the leader. Tried multiple times. Sometimes only the token directly behind the leader would follow, sometimes only the one at the back of the formation followed.

April 01 (4 years ago)
GiGs
Pro
Sheet Author
API Scripter


Stephen L. said:


Ravenknight said:


Persephone said:

@Ravenknight, I think just saving a single-file line formation should give you the effect you looking for?

If everybody are moving at once yea, but sometimes my players like to move around the map on their own with only one friend, an NPC or familiar as company. Having a quick button to add them to follow the character in question is a great benefit for me and the way we usually used Marching Order in the past. But considering how easy it is to create new formations it´s not a big thing. Just wondering if it can still be done.


I suppose that would still be useful to have an ad-hoc follow button for just simple old-style single-file formations that aren't saved. For the time being, it's formations only.

I second that request. I play a lot of Pendragon, where you play knights, and my players often need to jump on their horses and move around with it, then dismount or get unhorsed and have to move individually. They might also have a squire that follows them, as well or instead. having ad-hoc insta-formations for these situations would be very handy.

April 01 (4 years ago)

Edited April 01 (4 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter


Persephone said:

I should also clarify that the formation consisted of 4 tokens, but only 1 would follow the leader. Tried multiple times. Sometimes only the token directly behind the leader would follow, sometimes only the one at the back of the formation followed.


It sounds like that first token in the leader's list of followers is being moved to its pre-collision position in the formation, and then it's crashing during the collision detection with the dynamic lighting on the map.

Anything peculiar about the dynamic lighting?


Also, could you replace your version of the Token Collisions script with the following and let me know what messages appear in the API console?

https://gist.githubusercontent.com/Cazra/e41af0214f4b01a263441f44dc091c8d/raw/8e874ab8ffb5c28d436a25456de1201e56956c36/TokenCollisions%2520DEBUG

So far it has worked perfectly in tests. Saturday I will see if my players can break it. I have confidence in them finding any weak spots.

An individual "Follow Him/Her" command for the players would be good. If it actually maintained the distance it would be even better, I could use it when they pick up an "interested" third party, like a wolf.

Installed the Debug script. Here's a GIF of what's happening:


Here's the message sent to chat each time I move Seelah:


Here's the Console Log:

"Handle Graphic Movement"
"Handle Status Marker Change"
"New Statuses:flying-flag"
"Old Statuses:"
"Handle Graphic Movement"
"TokenCollisions DEBUG - Segment:"
[null,null]
"MarchingOrder ERROR: Cannot read property '0' of undefined"
"TypeError: Cannot read property '0' of undefined\n at _.chain.map.seg (apiscript.js:24348:11)\n at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:205:24)\n at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1639:39)\n at _testCirclePolyCollision_clipSegments (apiscript.js:24341:6)\n at _testCirclePolyCollision (apiscript.js:24328:20)\n at _testCirclePathCollision (apiscript.js:24278:12)\n at _testCollision (apiscript.js:24503:12)\n at _.chain.map.other (apiscript.js:24057:18)\n at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:205:24)\n at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1639:39)"
"Handle Graphic Movement"
"TokenCollisions DEBUG - Segment:"
[null,null]
"MarchingOrder ERROR: Cannot read property '0' of undefined"
"TypeError: Cannot read property '0' of undefined\n at _.chain.map.seg (apiscript.js:24348:11)\n at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:205:24)\n at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1639:39)\n at _testCirclePolyCollision_clipSegments (apiscript.js:24341:6)\n at _testCirclePolyCollision (apiscript.js:24328:20)\n at _testCirclePathCollision (apiscript.js:24278:12)\n at _testCollision (apiscript.js:24503:12)\n at _.chain.map.other (apiscript.js:24057:18)\n at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:205:24)\n at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1639:39)"
"Handle Graphic Movement"
"Handle Graphic Movement"
"TokenCollisions DEBUG - Segment:"
[null,null]
"MarchingOrder ERROR: Cannot read property '0' of undefined"
"TypeError: Cannot read property '0' of undefined\n at _.chain.map.seg (apiscript.js:24348:11)\n at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:205:24)\n at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1639:39)\n at _testCirclePolyCollision_clipSegments (apiscript.js:24341:6)\n at _testCirclePolyCollision (apiscript.js:24328:20)\n at _testCirclePathCollision (apiscript.js:24278:12)\n at _testCollision (apiscript.js:24503:12)\n at _.chain.map.other (apiscript.js:24057:18)\n at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:205:24)\n at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1639:39)"
"Handle Graphic Movement"
"TokenCollisions DEBUG - Segment:"
[null,null]
"MarchingOrder ERROR: Cannot read property '0' of undefined"
"TypeError: Cannot read property '0' of undefined\n at _.chain.map.seg (apiscript.js:24348:11)\n at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:205:24)\n at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1639:39)\n at _testCirclePolyCollision_clipSegments (apiscript.js:24341:6)\n at _testCirclePolyCollision (apiscript.js:24328:20)\n at _testCirclePathCollision (apiscript.js:24278:12)\n at _testCollision (apiscript.js:24503:12)\n at _.chain.map.other (apiscript.js:24057:18)\n at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:205:24)\n at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1639:39)"
"Handle Graphic Movement"
"TokenCollisions DEBUG - Segment:"
[null,null]
"MarchingOrder ERROR: Cannot read property '0' of undefined"
"TypeError: Cannot read property '0' of undefined\n at _.chain.map.seg (apiscript.js:24348:11)\n at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:205:24)\n at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1639:39)\n at _testCirclePolyCollision_clipSegments (apiscript.js:24341:6)\n at _testCirclePolyCollision (apiscript.js:24328:20)\n at _testCirclePathCollision (apiscript.js:24278:12)\n at _testCollision (apiscript.js:24503:12)\n at _.chain.map.other (apiscript.js:24057:18)\n at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:205:24)\n at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1639:39)"


Persephone said:

Installed the Debug script. Here's a GIF of what's happening:


Here's the message sent to chat each time I move Seelah:


Here's the Console Log:

"Handle Graphic Movement"
"Handle Status Marker Change"
"New Statuses:flying-flag"
"Old Statuses:"
"Handle Graphic Movement"
"TokenCollisions DEBUG - Segment:"
[null,null]
"MarchingOrder ERROR: Cannot read property '0' of undefined"
"TypeError: Cannot read property '0' of undefined\n at _.chain.map.seg (apiscript.js:24348:11)\n at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:205:24)\n at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1639:39)\n at _testCirclePolyCollision_clipSegments (apiscript.js:24341:6)\n at _testCirclePolyCollision (apiscript.js:24328:20)\n at _testCirclePathCollision (apiscript.js:24278:12)\n at _testCollision (apiscript.js:24503:12)\n at _.chain.map.other (apiscript.js:24057:18)\n at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:205:24)\n at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1639:39)"
"Handle Graphic Movement"
"TokenCollisions DEBUG - Segment:"
[null,null]
"MarchingOrder ERROR: Cannot read property '0' of undefined"
"TypeError: Cannot read property '0' of undefined\n at _.chain.map.seg (apiscript.js:24348:11)\n at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:205:24)\n at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1639:39)\n at _testCirclePolyCollision_clipSegments (apiscript.js:24341:6)\n at _testCirclePolyCollision (apiscript.js:24328:20)\n at _testCirclePathCollision (apiscript.js:24278:12)\n at _testCollision (apiscript.js:24503:12)\n at _.chain.map.other (apiscript.js:24057:18)\n at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:205:24)\n at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1639:39)"
"Handle Graphic Movement"
"Handle Graphic Movement"
"TokenCollisions DEBUG - Segment:"
[null,null]
"MarchingOrder ERROR: Cannot read property '0' of undefined"
"TypeError: Cannot read property '0' of undefined\n at _.chain.map.seg (apiscript.js:24348:11)\n at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:205:24)\n at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1639:39)\n at _testCirclePolyCollision_clipSegments (apiscript.js:24341:6)\n at _testCirclePolyCollision (apiscript.js:24328:20)\n at _testCirclePathCollision (apiscript.js:24278:12)\n at _testCollision (apiscript.js:24503:12)\n at _.chain.map.other (apiscript.js:24057:18)\n at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:205:24)\n at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1639:39)"
"Handle Graphic Movement"
"TokenCollisions DEBUG - Segment:"
[null,null]
"MarchingOrder ERROR: Cannot read property '0' of undefined"
"TypeError: Cannot read property '0' of undefined\n at _.chain.map.seg (apiscript.js:24348:11)\n at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:205:24)\n at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1639:39)\n at _testCirclePolyCollision_clipSegments (apiscript.js:24341:6)\n at _testCirclePolyCollision (apiscript.js:24328:20)\n at _testCirclePathCollision (apiscript.js:24278:12)\n at _testCollision (apiscript.js:24503:12)\n at _.chain.map.other (apiscript.js:24057:18)\n at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:205:24)\n at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1639:39)"
"Handle Graphic Movement"
"TokenCollisions DEBUG - Segment:"
[null,null]
"MarchingOrder ERROR: Cannot read property '0' of undefined"
"TypeError: Cannot read property '0' of undefined\n at _.chain.map.seg (apiscript.js:24348:11)\n at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:205:24)\n at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1639:39)\n at _testCirclePolyCollision_clipSegments (apiscript.js:24341:6)\n at _testCirclePolyCollision (apiscript.js:24328:20)\n at _testCirclePathCollision (apiscript.js:24278:12)\n at _testCollision (apiscript.js:24503:12)\n at _.chain.map.other (apiscript.js:24057:18)\n at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:205:24)\n at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1639:39)"


Same thing here

Probably not the problem, but just to be thorough: Persephone, it looks like you are using the VTT Enhancement Suite. Have you tried with that disabled? Anthony V, do you have VTTES installed?

April 01 (4 years ago)

Edited April 01 (4 years ago)

I will try again without VTTES, but it was working fine a few days ago, and for some reason it I don't have this issue on the page I tested on in the first GIF I posted here. I'm always moving the player ribbon to the page I'm testing on, too.

EDIT: Issue persists with the extension disabled.

I'm using the same Formation on both pages, and I've tried deleting and replacing all the tokens as well.

April 01 (4 years ago)

Edited April 01 (4 years ago)

Trying to use the formation on any other page with those tokens results in this error in the console log, even if I copy those exact tokens to the other page:

"MarchingOrder ERROR: Token with ID Seelah Rosebrew does not exist."
"Error: Token with ID Seelah Rosebrew does not exist.\n at _findPersistedToken (apiscript.js:22921:11)\n at Object.useFormation (apiscript.js:23269:18)\n at _cmdUseFormation (apiscript.js:23446:21)\n at msg (apiscript.js:23482:9)\n at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:154:1), <anonymous>:65:16)\n at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:154:1), <anonymous>:70:8)\n at /home/node/d20-api-server/api.js:1648:12\n at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560\n at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147)\n at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546)"

Maybe it is the dynamic lighting though. It's working fine on a new  blank page.

This page works, as does a blank page:


This page gives the above error when trying to use a formation (no objects on Lighting layer):


This page gives the initial error, and only one random follower stays in formation:


April 01 (4 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter


Persephone said:

I'm using the same Formation on both pages, and I've tried deleting and replacing all the tokens as well.

From the console messages you provided earlier, it looks like an issue with the dynamic lighting walls, not the tokens.
It should apply the formation on the new page as long as the tokens either represent a character whose name matches that name or whose token's name matches that name. It has to match exactly though.

In each instance, I'm using the same tokens that I used to create the Formation.

April 01 (4 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter


Persephone said:

In each instance, I'm using the same tokens that I used to create the Formation.


Can I assume correctly that "Seelah Rosebrew" is the exact name of the character, as it appears on the character object, and that "Seelah" is the exact name of the token as it appears in that token's settings?


Yes, both are correct

April 01 (4 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter


Persephone said:

Yes, both are correct

For now, I'm completely stumped then on why it's not able to find Seelah when you use the formation on the other map...


On the map that you DO have dynamic lighting walls, are all of them polylines? Do you also have rectangles or cricles used anywhere, or even some freehand lines? (I've tested against all of these so far without running into any issues, but Path Math dissects them differently to create line segments from them for collisions)

All the walls seem to be polylines. The map that IS working has a single circle changed to a polygon by the DLEllipseDrawer script. And the map with no walls whatsoever (the town map in my post above) doesn't allow me to make use formations at all.
April 01 (4 years ago)

Edited April 01 (4 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter


Persephone said:

All the walls seem to be polylines. The map that IS working has a single circle changed to a polygon by the DLEllipseDrawer script. And the map with no walls whatsoever (the town map in my post above) doesn't allow me to make use formations at all.


Try replacing your Path Math script with the following, and let me know what you get from it in the API console:

https://gist.githubusercontent.com/Cazra/abbebd895d89abdf2502ff9e15cc9dd4/raw/b9200f2adc47e156b57a9aaf67758a7bd5c4ba69/PathMath%2520DEBUG


April 01 (4 years ago)

Edited April 01 (4 years ago)


Stephen L. said:


Persephone said:

All the walls seem to be polylines. The map that IS working has a single circle changed to a polygon by the DLEllipseDrawer script. And the map with no walls whatsoever (the town map in my post above) doesn't allow me to make use formations at all.


Try replacing your Path Math script with the following, and let me know what you get from it in the API console:

https://gist.githubusercontent.com/Cazra/abbebd895d89abdf2502ff9e15cc9dd4/raw/b9200f2adc47e156b57a9aaf67758a7bd5c4ba69/PathMath%2520DEBUG



that unfortunatly did not work for my game and it did increase the lag substationally in the api.


Edit: seems to work on a map that has no DL.

I can test it out in a few hours. If that doesn't work I can invite you to the game, Stephen

April 02 (4 years ago)

Edited April 02 (4 years ago)

On the second and third maps (no DL and quite a bit of DL, respectively), with the PathMath debug and TokenCollision debug installed, I'm now getting this in the console log, and the formation doesn't get used

"MarchingOrder ERROR: Token with ID Seelah Rosebrew does not exist."
"Error: Token with ID Seelah Rosebrew does not exist.\n    at _findPersistedToken (apiscript.js:19155:11)\n    at Object.useFormation (apiscript.js:19503:18)\n    at _cmdUseFormation (apiscript.js:19680:21)\n    at msg (apiscript.js:19716:9)\n    at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:154:1), <anonymous>:65:16)\n    at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:154:1), <anonymous>:70:8)\n    at /home/node/d20-api-server/api.js:1648:12\n    at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560\n    at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147)\n    at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546)"

The first map (blank except for a large rectangular polygon and a small circular polygon) still works fine, and I get a huge amount of console output from just a few moves, which I'll PM to you so I don't inconvenience anyone trying to read this thread.

EDIT: This error was due to the Bump script (creates an invisible copy of the token on the GM layer). I've disabled all scripts that MarchingOrder doesn't rely on, and deleted the Bump tokens. No longer getting this error, but still getting the "property '0' of undefined" error that's causing only one token to follow instead of the whole formation.

Is there any way to have the script ignore tokens on the GM layer that would have the same name? If not, I can just delete the Bump tokens when the party uses MarchingOrder.

April 02 (4 years ago)

Edited April 02 (4 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter


Persephone said:

On the second and third maps (no DL and quite a bit of DL, respectively), with the PathMath debug and TokenCollision debug installed, I'm now getting this in the console log, and the formation doesn't get used

"MarchingOrder ERROR: Token with ID Seelah Rosebrew does not exist."
"Error: Token with ID Seelah Rosebrew does not exist.\n    at _findPersistedToken (apiscript.js:19155:11)\n    at Object.useFormation (apiscript.js:19503:18)\n    at _cmdUseFormation (apiscript.js:19680:21)\n    at msg (apiscript.js:19716:9)\n    at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:154:1), <anonymous>:65:16)\n    at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:154:1), <anonymous>:70:8)\n    at /home/node/d20-api-server/api.js:1648:12\n    at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560\n    at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147)\n    at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546)"

The first map (blank except for a large rectangular polygon and a small circular polygon) still works fine, and I get a huge amount of console output from just a few moves, which I'll PM to you so I don't inconvenience anyone trying to read this thread.

EDIT: This error was due to the Bump script (creates an invisible copy of the token on the GM layer). I've disabled all scripts that MarchingOrder doesn't rely on, and deleted the Bump tokens. No longer getting this error, but still getting the "property '0' of undefined" error that's causing only one token to follow instead of the whole formation.

Is there any way to have the script ignore tokens on the GM layer that would have the same name? If not, I can just delete the Bump tokens when the party uses MarchingOrder.

Nice! That solves that mystery then. Yes, I'll modify the script so that it only searches for the tokens on the objects layer. 

I'll take a look at the API console output in your PM soon to try to address the other issue.


Anthony V. said:

that unfortunatly did not work for my game and it did increase the lag substationally in the api.

Edit: seems to work on a map that has no DL.

I just inserted some logs for debugging the issue. Nothing was actually fixed in that version of the script yet.

April 02 (4 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter

I've got the issue Anthony and Persephone were having fixed. 

If anyone is having that problem, use the following update to the Path Math script to fix it:

https://gist.githubusercontent.com/Cazra/abbebd895d89abdf2502ff9e15cc9dd4/raw/a8ccbd9a840f257105ef478509b7e4541584b0d8/PathMath%2520DEBUG


Stephen L. said:

I've got the issue Anthony and Persephone were having fixed. 

If anyone is having that problem, use the following update to the Path Math script to fix it:

https://gist.githubusercontent.com/Cazra/abbebd895d89abdf2502ff9e15cc9dd4/raw/a8ccbd9a840f257105ef478509b7e4541584b0d8/PathMath%2520DEBUG


Unfortunatly I tested it and am no longer getting that error but tokens are going outside the DL lines when moving them.

April 02 (4 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter


Anthony V. said:


Stephen L. said:

I've got the issue Anthony and Persephone were having fixed. 

If anyone is having that problem, use the following update to the Path Math script to fix it:

https://gist.githubusercontent.com/Cazra/abbebd895d89abdf2502ff9e15cc9dd4/raw/a8ccbd9a840f257105ef478509b7e4541584b0d8/PathMath%2520DEBUG


Unfortunatly I tested it and am no longer getting that error but tokens are going outside the DL lines when moving them.

Could you share a screenshot of the dynamic lighting setup you've got?


April 07 (4 years ago)
Ada L.
Marketplace Creator
Sheet Author
API Scripter

Update: version 3.1

This new version is now available through the One-Click API library. Here's what's new:

* Added button for creating ad-hoc formations that aren't saved.
* Added button for making one token follow another at some set distance as an ad-hoc formation.
* Reorganized the menu a little bit.
* Formations will only look for their tokens on the objects layer when they are applied.

April 07 (4 years ago)
Ravenknight
KS Backer

Thank you, Stephen!

Question: does this script support custom status markers? I really want to start using Marching Orders, but I don't want the black flag or flying flag as the leader marker options.


Jay R. said:

Question: does this script support custom status markers? I really want to start using Marching Orders, but I don't want the black flag or flying flag as the leader marker options.


You actually don't see the status when they are marching it's just part of initial set up.


Anthony V. said:


Jay R. said:

Question: does this script support custom status markers? I really want to start using Marching Orders, but I don't want the black flag or flying flag as the leader marker options.


You actually don't see the status when they are marching it's just part of initial set up.


Good to know. Thank you!